24 #include "CharsetMapImpl.h"
28 #include "my_global.h"
32 #define MYSQL_BINARY_CHARSET 63
39 void CharsetMapImpl::build_map()
48 put(
"latin1" ,
"windows-1252");
49 put(
"latin2" ,
"ISO-8859-2");
50 put(
"greek" ,
"ISO-8859-7");
51 put(
"hebrew",
"ISO-8859-8");
52 put(
"latin5",
"ISO-8859-9");
53 put(
"latin7",
"ISO-8859-13");
56 put(
"cp850",
"IBM850");
57 put(
"cp852",
"IBM852");
58 put(
"cp866",
"IBM866");
59 put(
"cp1250",
"windows-1250");
60 put(
"cp1251",
"windows-1251");
61 put(
"cp1256",
"windows-1256");
62 put(
"cp1257",
"windows-1257");
65 put(
"ujis",
"EUC-JP");
66 put(
"euckr",
"EUC-KR");
67 put(
"cp932",
"windows-31j");
68 put(
"eucjpms",
"EUC_JP_Solaris");
69 put(
"tis620",
"TIS-620");
73 put(
"utf8mb3",
"UTF-8");
74 put(
"utf8mb4",
"UTF-8");
75 put(
"ucs2",
"UTF-16");
76 put(
"utf16",
"UTF-16");
77 put(
"utf32",
"UTF-32");
85 put(
"hp8",
"HP-ROMAN-8");
86 put(
"swe7",
"ISO646-SE");
87 put(
"koi8r",
"KOI8-R");
88 put(
"koi8u",
"KOI8-U");
89 put(
"macce",
"MacCentralEurope");
92 for(
unsigned int i = 0 ;
i < 255 ;
i++)
95 register const char *mysql_name = 0;
96 const char *mapped_name = 0;
100 mysql_name = cs->csname;
101 mapped_name =
get(mysql_name);
102 if(! cs_ucs2 && ! strcmp(mysql_name,
"ucs2")) cs_ucs2 =
i;
103 if(! cs_utf16 && ! strcmp(mysql_name,
"utf16")) cs_utf16 =
i;
104 if(! cs_utf8 && ! strcmp(mysql_name,
"utf8")) cs_utf8 =
i;
105 if(! cs_utf8_3 && ! strcmp(mysql_name,
"utf8mb3")) cs_utf8_3 =
i;
106 if(! cs_utf8_4 && ! strcmp(mysql_name,
"utf8mb4")) cs_utf8_4 =
i;
109 if(mapped_name) mysql_charset_name[
i] = mapped_name;
110 else mysql_charset_name[
i] = mysql_name;
114 UTF16Charset = cs_utf16;
116 UTF16Charset = cs_ucs2;
121 UTF8Charset = cs_utf8_4;
123 UTF8Charset = cs_utf8_3;
125 UTF8Charset = cs_utf8;
135 if((csnum > 255) || (csnum < 0))
139 return mysql_charset_name[csnum];
143 inline int CharsetMapImpl::hash(
const char *
name)
const
145 const unsigned char *p;
148 for (p = (
const unsigned char *) name ; *p !=
'\0' ; p++)
150 return h % CHARSET_MAP_HASH_TABLE_SIZE;
154 void CharsetMapImpl::put(
const char *name,
const char *value)
156 unsigned int h = hash(name);
171 const char * CharsetMapImpl::get(
const char *name)
const
173 unsigned int h = hash(name);
177 for( ;
i ; i = i->next)
179 if(! strcmp(name, i->name))
return i->value;