static string FontChar(uint moji1, uint moji2, PatchUtil.PRIORITY_CODE priorityCode) { SystemTextEncoder encoder = Program.SystemTextEncoder; if (priorityCode == PatchUtil.PRIORITY_CODE.SJIS) { if (U.isSJIS1stCode((byte)moji1) && U.isSJIS2ndCode((byte)moji2)) { byte[] str = new byte[3]; str[0] = (byte)moji1; str[1] = (byte)moji2; str[2] = 0; return(encoder.Decode(str, 0, 2)); } } if (moji1 == 0) { byte[] str = new byte[2]; str[0] = (byte)moji2; str[1] = 0; return(encoder.Decode(str, 0, 1)); } //意味不明な文字 return(U.ToCharOneHex((byte)moji1) + "_" + U.ToCharOneHex((byte)moji2)); }
string ConvertASCII(byte[] byte16) { PatchUtil.PRIORITY_CODE priorityCode = PatchUtil.SearchPriorityCode(); SystemTextEncoder encoder = Program.SystemTextEncoder; StringBuilder sb = new StringBuilder(); for (int i = 0; i < 16; i++) { if (i >= byte16.Length) { break; } if (priorityCode == PatchUtil.PRIORITY_CODE.UTF8) { sb.Append((char)byte16[i]); continue; } else if (i < 15 && U.isSJIS1stCode(byte16[i]) && U.isSJIS2ndCode(byte16[i + 1])) { if (priorityCode == PatchUtil.PRIORITY_CODE.LAT1) { //SJISと 1バイトUnicodeは範囲が重複するので、どちらかを優先しないといけない. if (byte16[i] >= 0x81 && byte16[i] < 0xFE) { //英語版FEにはUnicodeの1バイトだけ表記があるらしい. sb.Append((char)byte16[i]); sb.Append((char)byte16[i + 1]); i++; continue; } } sb.Append(encoder.Decode(byte16, i, 2)); i++; continue; } if (U.isAscii(byte16[i])) { sb.Append((char)byte16[i]); continue; } if (byte16[i] >= 0x81 && byte16[i] < 0xFE) {//FE独自フォントの可能性. if (priorityCode == PatchUtil.PRIORITY_CODE.LAT1) { sb.Append((char)byte16[i]); continue; } } //不明なコード sb.Append('.'); } return(sb.ToString()); }