@class AngbandView;
#ifdef JP
-static wchar_t convert_two_byte_eucjp_to_utf16_native(const char *cp);
+static wchar_t convert_two_byte_eucjp_to_utf32_native(const char *cp);
#endif
/**
*/
break;
}
- cellsRow[i].v.ch.glyph = convert_two_byte_eucjp_to_utf16_native(g);
+ cellsRow[i].v.ch.glyph = convert_two_byte_eucjp_to_utf32_native(g);
cellsRow[i].v.ch.attr = a;
cellsRow[i].hscl = 2;
cellsRow[i].vscl = 1;
#ifdef JP
/**
* Convert a two-byte EUC-JP encoded character (both *cp and (*cp + 1) are in
- * the range, 0xA1-0xFE, or *cp is 0x8E) to a utf16 value in the native byte
- * ordering.
+ * the range, 0xA1-0xFE, or *cp is 0x8E) to a UTF-32 (as a wchar_t) value in
+ * the native byte ordering.
*/
-static wchar_t convert_two_byte_eucjp_to_utf16_native(const char *cp)
+static wchar_t convert_two_byte_eucjp_to_utf32_native(const char *cp)
{
NSString* str = [[NSString alloc] initWithBytes:cp length:2
encoding:NSJapaneseEUCStringEncoding];
- wchar_t result = [str characterAtIndex:0];
+ wchar_t result;
+ UniChar first = [str characterAtIndex:0];
+
+ if (CFStringIsSurrogateHighCharacter(first)) {
+ result = CFStringGetLongCharacterForSurrogatePair(
+ first, [str characterAtIndex:1]);
+ } else {
+ result = first;
+ }
str = nil;
return result;
}