Skip to content

Commit

Permalink
[CONJ-22] adding charset
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Sep 18, 2015
1 parent b186cc5 commit 5a1772f
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 3 deletions.
159 changes: 158 additions & 1 deletion src/main/java/org/mariadb/jdbc/internal/common/CharsetUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static MySQLCharset getServerCharset(int serverCharsetByte) {
case 21:
case 27:
case 77:
return MySQLCharset.ISO8859_2;
return MySQLCharset.LATIN2;
case 3:
case 69:
return MySQLCharset.CP1252;
Expand All @@ -81,11 +81,26 @@ public static MySQLCharset getServerCharset(int serverCharsetByte) {
case 49:
case 94:
return MySQLCharset.LATIN1;
case 6:
case 72:
return MySQLCharset.HP8;
case 7:
case 74:
return MySQLCharset.KOI8R;
case 10:
case 82:
return MySQLCharset.SWE7;
case 11:
case 65:
case 92:
case 93:
return MySQLCharset.ASCII;
case 12:
case 91:
return MySQLCharset.UJIS;
case 13:
case 88:
return MySQLCharset.SJIS;
case 14:
case 23:
case 50:
Expand All @@ -95,9 +110,20 @@ public static MySQLCharset getServerCharset(int serverCharsetByte) {
case 16:
case 71:
return MySQLCharset.HEBREW;
case 18:
case 89:
return MySQLCharset.TIS620;
case 19:
case 85:
return MySQLCharset.EUCKR;
case 20:
case 41:
case 42:
case 79:
return MySQLCharset.LATIN7;
case 22:
case 75:
return MySQLCharset.KOI8U;
case 24:
case 86:
return MySQLCharset.GB2312;
Expand All @@ -117,12 +143,54 @@ public static MySQLCharset getServerCharset(int serverCharsetByte) {
case 58:
case 59:
return MySQLCharset.CP1257;
case 30:
case 78:
return MySQLCharset.LATIN5;
case 32:
case 64:
return MySQLCharset.ARMSCII8;
case 35:
case 90:
case 128:
case 129:
case 130:
case 131:
case 132:
case 133:
case 134:
case 135:
case 136:
case 137:
case 138:
case 139:
case 140:
case 141:
case 142:
case 143:
case 144:
case 145:
case 146:
case 147:
case 148:
case 149:
case 150:
case 151:
case 159:
case 640:
case 641:
return MySQLCharset.UCS2;
case 36:
case 68:
return MySQLCharset.CP866;
case 37:
case 73:
return MySQLCharset.KEYBCS2;
case 38:
case 43:
return MySQLCharset.MACCE;
case 39:
case 53:
return MySQLCharset.MACROMAN;
case 40:
case 81:
return MySQLCharset.CP852;
Expand Down Expand Up @@ -156,9 +224,98 @@ public static MySQLCharset getServerCharset(int serverCharsetByte) {
case 576:
case 577:
return MySQLCharset.UTF8;
case 45:
case 46:
case 224:
case 225:
case 226:
case 227:
case 228:
case 229:
case 230:
case 231:
case 232:
case 233:
case 234:
case 235:
case 236:
case 237:
case 238:
case 239:
case 240:
case 241:
case 242:
case 243:
case 244:
case 245:
case 246:
case 247:
case 608:
case 609:
return MySQLCharset.UTF8MB4;
case 54:
case 55:
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
case 107:
case 108:
case 109:
case 110:
case 111:
case 112:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
case 119:
case 121:
case 122:
case 123:
case 124:
case 672:
case 673:
return MySQLCharset.UTF16;
case 56:
case 62:
return MySQLCharset.UTF16LE;
case 57:
case 67:
return MySQLCharset.CP1256;
case 60:
case 61:
case 160:
case 161:
case 162:
case 163:
case 164:
case 165:
case 166:
case 167:
case 168:
case 169:
case 170:
case 171:
case 172:
case 173:
case 174:
case 175:
case 176:
case 177:
case 178:
case 179:
case 180:
case 181:
case 182:
case 183:
case 736:
case 737:
return MySQLCharset.UTF32;
case 63:
return MySQLCharset.BINARY;
case 95:
Expand Down
21 changes: 19 additions & 2 deletions src/main/java/org/mariadb/jdbc/internal/common/MySQLCharset.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,41 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS

public enum MySQLCharset {
BIG5(1, "big5", "Big5", "Big5"),
ISO8859_2(2, "latin2", "ISO8859_2", "ISO-8859-2"),
CP1252(3, "dec8", "Cp1252", "windows-1252"),
CP850(4, "cp850", "Cp850", "IBM850"),
HP8(6,"hp8","Cp1252","windows-1252"), //
KOI8R(7,"koi8r","KOI8_R","KOI8-R"),
LATIN1(8, "latin1", "ISO8859_1", "ISO-8859-1"),
LATIN2(9, "latin2", "ISO8859_2", "ISO-8859-2"),
SWE7(10,"swe7", "Cp1252", "windows-1252"),
ASCII(11,"ascii","ASCII", "US-ASCII"),
UJIS(12,"ujis","EUC_JP","EUC-JP"),
SJIS(13,"sjis","SJIS","Shift_JIS"),
HEBREW(16,"hebrew","ISO8859_8","ISO-8859-8"),
TIS620(18,"tis620","TIS620","TIS-620"),
EUCKR(19,"euckr","EUC_KR", "EUC-KR"),
KOI8U(22,"koi8u","KOI8_U","KOI8-U"),
GB2312(24,"gb2312","EUC_CN","GB2312"),
GREEK(25,"greek","ISO8859_7","ISO-8859-7"),
CP1250(26,"cp1250","Cp1250","windows-1250"),
GBK(28,"gbk","GBK","GBK"),
LATIN5(30,"latin5","ISO8859_9","ISO-8859-9"),
ARMSCII8(32, "armscii8", "ISO8859_1", "ISO-8859-1"),
UTF8(33, "utf8", "UTF8", "UTF-8"),
UCS2(35,"ucs2","UnicodeBig", null),
CP866(36, "cp866", "Cp866", "IBM866"),
KEYBCS2(37, "keybcs2", "Cp852", "IBM852"), //Cp895 not supported by java
MACCE(38,"macce","MacCentralEurope","x-MacCentralEurope"),
MACROMAN(39,"macroman","MacRoman","x-MacRoman"),
CP852(40, "cp852", "Cp852", "IBM852"),
UTF8MB4(45,"utf8mb4","UTF-8","UTF-8"),
LATIN7(41,"latin7","ISO8859_13","ISO-8859-13"),
CP1251(51,"cp1251","Cp1251","windows-1251"),
CP1256(56,"cp1256","Cp1256","windows-1256"),
UTF16(54,"utf16","UTF-16","UTF-16"),
UTF16LE(56,"utf16le","UnicodeLittleUnmarked","UTF-16LE"),
CP1256(57,"cp1256","Cp1256","windows-1256"),
CP1257(59,"cp1257","Cp1257","windows-1257"),
UTF32(60,"utf32","UTF_32","UTF-32"),
BINARY(63,"binary",null,null),
GEOSTD8(92,"geostd8","Cp942","x-IBM942"),
CP932(95,"cp932","Cp942","x-IBM942"),
Expand Down

0 comments on commit 5a1772f

Please sign in to comment.