📄 charset.c
字号:
name [i] = '\0'; if (strstr (name, "ISO") && strstr (name, "8859-8")) return 0; if (strstr (name, "HEBREW")) return 0; return 1;}#ifdef _UNICODE_SUPPORTstatic unsigned short iso8859_8_conv_to_uc16 (const unsigned char* mchar, int len){ if (*mchar >= 0xE0 && *mchar <= 0xFA) { return *mchar - 0xE0 + 0x05D0; } else { switch (*mchar) { case 0xAA: return 0x00D7; case 0xBA: return 0x00F7; case 0xDF: return 0x2017; case 0xFD: return 0x200E; case 0xFE: return 0x200F; } return (unsigned short) (*mchar); }}#endifstatic CHARSETOPS CharsetOps_iso8859_8 = { 256, 1, 1, FONT_CHARSET_ISO8859_8, {' '}, sb_len_first_char, sb_char_offset, sb_nr_chars_in_str, iso8859_8_is_this_charset, sb_len_first_substr, sb_get_next_word, sb_pos_first_char,#ifdef _UNICODE_SUPPORT iso8859_8_conv_to_uc16#endif};#endif /* _GREEK_SUPPORT */#ifdef _LATIN5_SUPPORT/************************* ISO8859-9 Specific Operations **********************/static int iso8859_9_is_this_charset (const unsigned char* charset){ int i; char name [LEN_FONT_NAME + 1]; for (i = 0; i < LEN_FONT_NAME + 1; i++) { if (charset [i] == '\0') break; name [i] = toupper (charset [i]); } name [i] = '\0'; if (strstr (name, "ISO") && strstr (name, "8859-9")) return 0; if (strstr (name, "LATIN5")) return 0; return 1;}#ifdef _UNICODE_SUPPORTstatic unsigned short iso8859_9_conv_to_uc16 (const unsigned char* mchar, int len){ switch (*mchar) { case 0xD0: return 0x011E; case 0xDD: return 0x0130; case 0xDE: return 0x015E; case 0xF0: return 0x011F; case 0xFD: return 0x0131; case 0xFE: return 0x015F; } return (unsigned short) (*mchar);}#endifstatic CHARSETOPS CharsetOps_iso8859_9 = { 256, 1, 1, FONT_CHARSET_ISO8859_9, {' '}, sb_len_first_char, sb_char_offset, sb_nr_chars_in_str, iso8859_9_is_this_charset, sb_len_first_substr, sb_get_next_word, sb_pos_first_char,#ifdef _UNICODE_SUPPORT iso8859_9_conv_to_uc16#endif};#endif /* _LATIN5_SUPPORT */#ifdef _LATIN6_SUPPORT/************************* ISO8859-10 Specific Operations **********************/static int iso8859_10_is_this_charset (const unsigned char* charset){ int i; char name [LEN_FONT_NAME + 1]; for (i = 0; i < LEN_FONT_NAME + 1; i++) { if (charset [i] == '\0') break; name [i] = toupper (charset [i]); } name [i] = '\0'; if (strstr (name, "ISO") && strstr (name, "8859-10")) return 0; if (strstr (name, "LATIN6")) return 0; return 1;}#ifdef _UNICODE_SUPPORTstatic unsigned short iso8859_10_unicode_map [] ={ 0x0104, 0x0112, 0x0122, 0x012A, 0x0128, 0x0136, 0x00A7, 0x013B, 0x0110, 0x0160, 0x0166, 0x017D, 0x00AD, 0x016A, 0x014A, 0x00B0, 0x0105, 0x0113, 0x0123, 0x012B, 0x0129, 0x0137, 0x00B7, 0x013C, 0x0111, 0x0161, 0x0167, 0x017E, 0x2015, 0x016B, 0x014B, 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x00CF, 0x00D0, 0x0145, 0x014C, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0168, 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169, 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138};static unsigned short iso8859_10_conv_to_uc16 (const unsigned char* mchar, int len){ if (*mchar < 0xA1) return (unsigned short) (*mchar); else return iso8859_10_unicode_map [*mchar - 0xA1];}#endifstatic CHARSETOPS CharsetOps_iso8859_10 = { 256, 1, 1, FONT_CHARSET_ISO8859_10, {' '}, sb_len_first_char, sb_char_offset, sb_nr_chars_in_str, iso8859_10_is_this_charset, sb_len_first_substr, sb_get_next_word, sb_pos_first_char,#ifdef _UNICODE_SUPPORT iso8859_10_conv_to_uc16#endif};#endif /* _LATIN6_SUPPORT */#ifdef _THAI_SUPPORT/************************* ISO8859-11 Specific Operations **********************/static int iso8859_11_is_this_charset (const unsigned char* charset){ int i; char name [LEN_FONT_NAME + 1]; for (i = 0; i < LEN_FONT_NAME + 1; i++) { if (charset [i] == '\0') break; name [i] = toupper (charset [i]); } name [i] = '\0'; if (strstr (name, "ISO") && strstr (name, "8859-11")) return 0; if (strstr (name, "TIS") && strstr (name, "620")) return 0; return 1;}#ifdef _UNICODE_SUPPORTstatic unsigned short iso8859_11_unicode_map [] ={ 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07, 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F, 0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17, 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F, 0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27, 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F, 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, 0x0E38, 0x0E39, 0x0E3A, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x0E3F, 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47, 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F, 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x00FC, 0x00FD, 0x00FE, 0x00FF};static unsigned short iso8859_11_conv_to_uc16 (const unsigned char* mchar, int len){ if (*mchar < 0xA1) return (unsigned short) (*mchar); else return iso8859_11_unicode_map [*mchar - 0xA1];}#endifstatic CHARSETOPS CharsetOps_iso8859_11 = { 256, 1, 1, FONT_CHARSET_ISO8859_11, {' '}, sb_len_first_char, sb_char_offset, sb_nr_chars_in_str, iso8859_11_is_this_charset, sb_len_first_substr, sb_get_next_word, sb_pos_first_char,#ifdef _UNICODE_SUPPORT iso8859_11_conv_to_uc16#endif};#endif /* _THAI_SUPPORT */#ifdef _LATIN7_SUPPORT/************************* ISO8859-13 Specific Operations **********************/static int iso8859_13_is_this_charset (const unsigned char* charset){ int i; char name [LEN_FONT_NAME + 1]; for (i = 0; i < LEN_FONT_NAME + 1; i++) { if (charset [i] == '\0') break; name [i] = toupper (charset [i]); } name [i] = '\0'; if (strstr (name, "ISO") && strstr (name, "8859-13")) return 0; if (strstr (name, "LATIN7")) return 0; return 1;}#ifdef _UNICODE_SUPPORTstatic unsigned short iso8859_13_unicode_map [] ={ 0x201D, 0x00A2, 0x00A3, 0x00A4, 0x201E, 0x00A6, 0x00A7, 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6, 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x201C, 0x00B5, 0x00B6, 0x00B7, 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6, 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x2019};static unsigned short iso8859_13_conv_to_uc16 (const unsigned char* mchar, int len){ if (*mchar < 0xA1) return (unsigned short) (*mchar); else return iso8859_13_unicode_map [*mchar - 0xA1];}#endifstatic CHARSETOPS CharsetOps_iso8859_13 = { 256, 1, 1, FONT_CHARSET_ISO8859_13, {' '}, sb_len_first_char, sb_char_offset, sb_nr_chars_in_str, iso8859_13_is_this_charset, sb_len_first_substr, sb_get_next_word, sb_pos_first_char,#ifdef _UNICODE_SUPPORT iso8859_13_conv_to_uc16#endif};#endif /* _LATIN7_SUPPORT */#ifdef _LATIN8_SUPPORT/************************* ISO8859-14 Specific Operations **********************/static int iso8859_14_is_this_charset (const unsigned char* charset){ int i; char name [LEN_FONT_NAME + 1]; for (i = 0; i < LEN_FONT_NAME + 1; i++) { if (charset [i] == '\0') break; name [i] = toupper (charset [i]); } name [i] = '\0'; if (strstr (name, "ISO") && strstr (name, "8859-14")) return 0; if (strstr (name, "LATIN8")) return 0; return 1;}#ifdef _UNICODE_SUPPORTstatic unsigned short iso8859_14_unicode_map [] ={ 0x1E02, 0x1E03, 0x00A3, 0x010A, 0x010B, 0x1E0A, 0x00A7, 0x1E80, 0x00A9, 0x1E82, 0x1E0B, 0x1EF2, 0x00AD, 0x00AE, 0x0178, 0x1E1E, 0x1E1F, 0x0120, 0x0121, 0x1E40, 0x1E41, 0x00B6, 0x1E56, 0x1E81, 0x1E57, 0x1E83, 0x1E60, 0x1EF3, 0x1E84, 0x1E85, 0x1E61, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x0174, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x1E6A, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x0176, 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x0175, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x1E6B, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF};static unsigned short iso8859_14_conv_to_uc16 (const unsigned char* mchar, int len){ if (*mchar < 0xA1) return (unsigned short) (*mchar); else return iso8859_14_unicode_map [*mchar - 0xA1];}#endifstatic CHARSETOPS CharsetOps_iso8859_14 = { 256, 1, 1, FONT_CHARSET_ISO8859_14, {' '}, sb_len_first_char, sb_char_offset, sb_nr_chars_in_str, iso8859_14_is_this_charset, sb_len_first_substr, sb_get_next_word, sb_pos_first_char,#ifdef _UNICODE_SUPPORT iso8859_14_conv_to_uc16#endif};#endif /* _LATIN8_SUPPORT */#ifdef _LATIN9_SUPPORT/************************* ISO8859-15 Specific Operations **********************/static int iso8859_15_is_this_charset (const unsigned char* charset){ int i; char name [LEN_FONT_NAME + 1]; for (i = 0; i < LEN_FONT_NAME + 1; i++) { if (charset [i] == '\0') break; name [i] = toupper (charset [i]); } name [i] = '\0'; if (strstr (name, "ISO") && strstr (name, "8859-15")) return 0; if (strstr (name, "LATIN") && strstr (name, "9")) return 0; return 1;}#ifdef _UNICODE_SUPPORTstatic unsigned short iso8859_15_conv_to_uc16 (const unsigned char* mchar, int len){ switch (*mchar) { case 0xA4: return 0x20AC; /* EURO SIGN */ case 0xA6: return 0x0160; /* LATIN CAPITAL LETTER S WITH CARO */ case 0xA8: return 0x0161; /* LATIN SMALL LETTER S WITH CARON */ case 0xB4: return 0x017D; /* LATIN CAPITAL LETTER Z WITH CARON */ case 0xB8: return 0x017E; /* LATIN SMALL LETTER Z WITH CARON */ case 0xBC: return 0x0152; /* LATIN CAPITAL LIGATURE OE */ case 0xBD: return 0x0153; /* LATIN SMALL LIGATURE OE */ case 0xBE: return 0x0178; /* LATIN CAPITAL LETTER Y WITH DIAERESIS */ default: return *mchar; }}#endifstatic CHARSETOPS CharsetOps_iso8859_15 = { 256, 1, 1, FONT_CHARSET_ISO8859_15, {' '}, sb_len_first_char, sb_char_offset, sb_nr_chars_in_str, iso8859_15_is_this_charset, sb_len_first_substr, sb_get_next_word, sb_pos_first_char,#ifdef _UNICODE_SUPPORT iso8859_15_conv_to_uc16#endif};#endif /* _LATIN9_SUPPORT */#ifdef _LATIN10_SUPPORT/************************* ISO8859-16 Specific Operations **********************/static int iso8859_16_is_this_charset (const unsigned char* charset){ int i; char name [LEN_FONT_NAME + 1]; for (i = 0; i < LEN_FONT_NAME + 1; i++) { if (charset [i] == '\0') break; name [i] = toupper (charset [i]); } name [i] = '\0'; if (strstr (name, "ISO") && strstr (name, "8859-16")) return 0; if (strstr (name, "LATIN") && strstr (name, "10")) return 0; return 1;}#ifdef _UNICODE_SUPPORTstatic unsigned short iso8859_16_conv_to_uc16 (const unsigned char* mchar, int len){ switch (*mchar) { case 0xA1: return 0x0104; case 0xA2: return 0x0105; case 0xA3: return 0x0141; case 0xA4: return 0x20AC; case 0xA5: return 0x201E; case 0xA6: return 0x0160; case 0xA8: return 0x0161; case 0xAA: return 0x0218; case 0xAC: return 0x0179; case 0xAE: return 0x017A; case 0xAF: return 0x017B; case 0xB2: return 0x010C; case 0xB3: return 0x0142; case 0xB4: return 0x017D; case 0xB5: return 0x201D; case 0xB8: return 0x017E; case 0xB9: return 0x010D; case 0xBA: return 0x0219; case 0xBC: return 0x0152; case 0xBD: return 0x0153; case 0xBE: return 0x0178; case 0xBF: return 0x017C; case 0xC3: return 0x0102; case 0xC5: return 0x0106; case 0xD0: return 0x0110; case 0xD1: return 0x0143; case 0xD5: return 0x0150; case 0xD7: return 0x015A; case 0xD8: return 0x0170; case 0xDD: return 0x0118; case 0xDE: return 0x021A; case 0xE3: return 0x0103; case 0xE5: return 0x0107; case 0xF0: return 0x0111; case 0xF1: return 0x0144; case 0xF5: return 0x0151; case 0xF7: return 0x015B; case 0xF8: return 0x0171; case 0xFD: return 0x0119; case 0xFE: return 0x021B; } return (unsigned short) (*mchar);}#endifstatic CHARSETOPS CharsetOps_iso8859_16 = { 256, 1, 1, FONT_CHARSET_ISO8859_16, {' '}, sb_len_first_char, sb_char_offset, sb_nr_chars_in_str, iso8859_16_is_this_charset, sb_len_first_substr, sb_get_next_word, sb_pos_first_char,#ifdef _UNICODE_SUPPORT iso8859_16_conv_to_uc16#endif};#endif /* _LATIN10_SUPPORT *//*************** Common Operations for double bytes charsets ******************/#if defined(_GB_SUPPORT) | defined(_GBK_SUPPORT) | defined(_BIG5_SUPPORT) \ | defined(_EUCKR_SUPPORT) | defined(_EUCJP_SUPPORT) | defined(_SHIFTJIS_SUPPORT) \ | defined(_UNICODE_SUPPORT)static int db_nr_chars_in_str (const unsigned char* mstr, int mstrlen){ assert ((mstrlen % 2) == 0); return mstrlen >> 1;}static const unsigned char* db_get_next_word (const unsigned char* mstr, int mstrlen, WORDINFO* word_info){ assert ((mstrlen % 2) == 0); if (mstrlen < 2) return NULL; word_info->len = 2; word_info->delimiter = '\0'; word_info->nr_delimiters = 0; return mstr + 2;}#endif#ifdef _GB_SUPPORT/************************* GB2312 Specific Operations ************************/#define IS_GB2312_CHAR(ch1, ch2) \ if (((ch1 >= 0xA1 && ch1 <= 0xA9) || (ch1 >= 0xB0 && ch1 <= 0xF7)) \ && ch2 >= 0xA1 && ch2 <= 0xFE)static int gb2312_0_len_first_char (const unsigned char* mstr, int len){ unsigned char ch1; unsigned char ch2; if (len < 2) return 0; ch1 = mstr [0]; if (ch1 == '\0') return 0; ch2 = mstr [1]; IS_GB2312_CHAR (ch1, ch2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -