ruby-mysql 2.9.13 → 2.11.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mysql/charset.rb CHANGED
@@ -17,174 +17,316 @@ class Mysql
17
17
  # @param [String] csname
18
18
  def initialize(number, name, csname)
19
19
  @number, @name, @csname = number, name, csname
20
- @unsafe = false
21
20
  end
22
21
 
23
22
  attr_reader :number, :name, :csname
24
23
 
25
- # @private
26
- attr_accessor :unsafe
27
-
28
24
  # [[charset_number, charset_name, collation_name, default], ...]
29
25
  # @private
30
26
  CHARSETS = [
31
- [ 1, "big5", "big5_chinese_ci", true ],
32
- [ 2, "latin2", "latin2_czech_cs", false],
33
- [ 3, "dec8", "dec8_swedish_ci", true ],
34
- [ 4, "cp850", "cp850_general_ci", true ],
35
- [ 5, "latin1", "latin1_german1_ci", false],
36
- [ 6, "hp8", "hp8_english_ci", true ],
37
- [ 7, "koi8r", "koi8r_general_ci", true ],
38
- [ 8, "latin1", "latin1_swedish_ci", true ],
39
- [ 9, "latin2", "latin2_general_ci", true ],
40
- [ 10, "swe7", "swe7_swedish_ci", true ],
41
- [ 11, "ascii", "ascii_general_ci", true ],
42
- [ 12, "ujis", "ujis_japanese_ci", true ],
43
- [ 13, "sjis", "sjis_japanese_ci", true ],
44
- [ 14, "cp1251", "cp1251_bulgarian_ci", false],
45
- [ 15, "latin1", "latin1_danish_ci", false],
46
- [ 16, "hebrew", "hebrew_general_ci", true ],
47
- [ 17, "filename", "filename", true ],
48
- [ 18, "tis620", "tis620_thai_ci", true ],
49
- [ 19, "euckr", "euckr_korean_ci", true ],
50
- [ 20, "latin7", "latin7_estonian_cs", false],
51
- [ 21, "latin2", "latin2_hungarian_ci", false],
52
- [ 22, "koi8u", "koi8u_general_ci", true ],
53
- [ 23, "cp1251", "cp1251_ukrainian_ci", false],
54
- [ 24, "gb2312", "gb2312_chinese_ci", true ],
55
- [ 25, "greek", "greek_general_ci", true ],
56
- [ 26, "cp1250", "cp1250_general_ci", true ],
57
- [ 27, "latin2", "latin2_croatian_ci", false],
58
- [ 28, "gbk", "gbk_chinese_ci", true ],
59
- [ 29, "cp1257", "cp1257_lithuanian_ci", false],
60
- [ 30, "latin5", "latin5_turkish_ci", true ],
61
- [ 31, "latin1", "latin1_german2_ci", false],
62
- [ 32, "armscii8", "armscii8_general_ci", true ],
63
- [ 33, "utf8", "utf8_general_ci", true ],
64
- [ 34, "cp1250", "cp1250_czech_cs", false],
65
- [ 35, "ucs2", "ucs2_general_ci", true ],
66
- [ 36, "cp866", "cp866_general_ci", true ],
67
- [ 37, "keybcs2", "keybcs2_general_ci", true ],
68
- [ 38, "macce", "macce_general_ci", true ],
69
- [ 39, "macroman", "macroman_general_ci", true ],
70
- [ 40, "cp852", "cp852_general_ci", true ],
71
- [ 41, "latin7", "latin7_general_ci", true ],
72
- [ 42, "latin7", "latin7_general_cs", false],
73
- [ 43, "macce", "macce_bin", false],
74
- [ 44, "cp1250", "cp1250_croatian_ci", false],
75
- [ 45, "utf8mb4", "utf8mb4_general_ci", true ],
76
- [ 46, "utf8mb4", "utf8mb4_bin", false],
77
- [ 47, "latin1", "latin1_bin", false],
78
- [ 48, "latin1", "latin1_general_ci", false],
79
- [ 49, "latin1", "latin1_general_cs", false],
80
- [ 50, "cp1251", "cp1251_bin", false],
81
- [ 51, "cp1251", "cp1251_general_ci", true ],
82
- [ 52, "cp1251", "cp1251_general_cs", false],
83
- [ 53, "macroman", "macroman_bin", false],
84
- [ 57, "cp1256", "cp1256_general_ci", true ],
85
- [ 58, "cp1257", "cp1257_bin", false],
86
- [ 59, "cp1257", "cp1257_general_ci", true ],
87
- [ 63, "binary", "binary", true ],
88
- [ 64, "armscii8", "armscii8_bin", false],
89
- [ 65, "ascii", "ascii_bin", false],
90
- [ 66, "cp1250", "cp1250_bin", false],
91
- [ 67, "cp1256", "cp1256_bin", false],
92
- [ 68, "cp866", "cp866_bin", false],
93
- [ 69, "dec8", "dec8_bin", false],
94
- [ 70, "greek", "greek_bin", false],
95
- [ 71, "hebrew", "hebrew_bin", false],
96
- [ 72, "hp8", "hp8_bin", false],
97
- [ 73, "keybcs2", "keybcs2_bin", false],
98
- [ 74, "koi8r", "koi8r_bin", false],
99
- [ 75, "koi8u", "koi8u_bin", false],
100
- [ 77, "latin2", "latin2_bin", false],
101
- [ 78, "latin5", "latin5_bin", false],
102
- [ 79, "latin7", "latin7_bin", false],
103
- [ 80, "cp850", "cp850_bin", false],
104
- [ 81, "cp852", "cp852_bin", false],
105
- [ 82, "swe7", "swe7_bin", false],
106
- [ 83, "utf8", "utf8_bin", false],
107
- [ 84, "big5", "big5_bin", false],
108
- [ 85, "euckr", "euckr_bin", false],
109
- [ 86, "gb2312", "gb2312_bin", false],
110
- [ 87, "gbk", "gbk_bin", false],
111
- [ 88, "sjis", "sjis_bin", false],
112
- [ 89, "tis620", "tis620_bin", false],
113
- [ 90, "ucs2", "ucs2_bin", false],
114
- [ 91, "ujis", "ujis_bin", false],
115
- [ 92, "geostd8", "geostd8_general_ci", true ],
116
- [ 93, "geostd8", "geostd8_bin", false],
117
- [ 94, "latin1", "latin1_spanish_ci", false],
118
- [ 95, "cp932", "cp932_japanese_ci", true ],
119
- [ 96, "cp932", "cp932_bin", false],
120
- [ 97, "eucjpms", "eucjpms_japanese_ci", true ],
121
- [ 98, "eucjpms", "eucjpms_bin", false],
122
- [ 99, "cp1250", "cp1250_polish_ci", false],
123
- [128, "ucs2", "ucs2_unicode_ci", false],
124
- [129, "ucs2", "ucs2_icelandic_ci", false],
125
- [130, "ucs2", "ucs2_latvian_ci", false],
126
- [131, "ucs2", "ucs2_romanian_ci", false],
127
- [132, "ucs2", "ucs2_slovenian_ci", false],
128
- [133, "ucs2", "ucs2_polish_ci", false],
129
- [134, "ucs2", "ucs2_estonian_ci", false],
130
- [135, "ucs2", "ucs2_spanish_ci", false],
131
- [136, "ucs2", "ucs2_swedish_ci", false],
132
- [137, "ucs2", "ucs2_turkish_ci", false],
133
- [138, "ucs2", "ucs2_czech_ci", false],
134
- [139, "ucs2", "ucs2_danish_ci", false],
135
- [140, "ucs2", "ucs2_lithuanian_ci", false],
136
- [141, "ucs2", "ucs2_slovak_ci", false],
137
- [142, "ucs2", "ucs2_spanish2_ci", false],
138
- [143, "ucs2", "ucs2_roman_ci", false],
139
- [144, "ucs2", "ucs2_persian_ci", false],
140
- [145, "ucs2", "ucs2_esperanto_ci", false],
141
- [146, "ucs2", "ucs2_hungarian_ci", false],
142
- [192, "utf8", "utf8_unicode_ci", false],
143
- [193, "utf8", "utf8_icelandic_ci", false],
144
- [194, "utf8", "utf8_latvian_ci", false],
145
- [195, "utf8", "utf8_romanian_ci", false],
146
- [196, "utf8", "utf8_slovenian_ci", false],
147
- [197, "utf8", "utf8_polish_ci", false],
148
- [198, "utf8", "utf8_estonian_ci", false],
149
- [199, "utf8", "utf8_spanish_ci", false],
150
- [200, "utf8", "utf8_swedish_ci", false],
151
- [201, "utf8", "utf8_turkish_ci", false],
152
- [202, "utf8", "utf8_czech_ci", false],
153
- [203, "utf8", "utf8_danish_ci", false],
154
- [204, "utf8", "utf8_lithuanian_ci", false],
155
- [205, "utf8", "utf8_slovak_ci", false],
156
- [206, "utf8", "utf8_spanish2_ci", false],
157
- [207, "utf8", "utf8_roman_ci", false],
158
- [208, "utf8", "utf8_persian_ci", false],
159
- [209, "utf8", "utf8_esperanto_ci", false],
160
- [210, "utf8", "utf8_hungarian_ci", false],
161
- [211, "utf8", "utf8_sinhala_ci", false],
162
- [224, "utf8mb4", "utf8mb4_unicode_ci", false],
163
- [225, "utf8mb4", "utf8mb4_icelandic_ci", false],
164
- [226, "utf8mb4", "utf8mb4_latvian_ci", false],
165
- [227, "utf8mb4", "utf8mb4_romanian_ci", false],
166
- [228, "utf8mb4", "utf8mb4_slovenian_ci", false],
167
- [229, "utf8mb4", "utf8mb4_polish_ci", false],
168
- [230, "utf8mb4", "utf8mb4_estonian_ci", false],
169
- [231, "utf8mb4", "utf8mb4_spanish_ci", false],
170
- [232, "utf8mb4", "utf8mb4_swedish_ci", false],
171
- [233, "utf8mb4", "utf8mb4_turkish_ci", false],
172
- [234, "utf8mb4", "utf8mb4_czech_ci", false],
173
- [235, "utf8mb4", "utf8mb4_danish_ci", false],
174
- [236, "utf8mb4", "utf8mb4_lithuanian_ci", false],
175
- [237, "utf8mb4", "utf8mb4_slovak_ci", false],
176
- [238, "utf8mb4", "utf8mb4_spanish2_ci", false],
177
- [239, "utf8mb4", "utf8mb4_roman_ci", false],
178
- [240, "utf8mb4", "utf8mb4_persian_ci", false],
179
- [241, "utf8mb4", "utf8mb4_esperanto_ci", false],
180
- [242, "utf8mb4", "utf8mb4_hungarian_ci", false],
181
- [243, "utf8mb4", "utf8mb4_sinhala_ci", false],
182
- [254, "utf8", "utf8_general_cs", false],
183
- ]
184
-
185
- # @private
186
- UNSAFE_CHARSET = [
187
- "big5", "sjis", "filename", "gbk", "ucs2", "cp932",
27
+ [ 1, "big5", "big5_chinese_ci", true ],
28
+ [ 2, "latin2", "latin2_czech_cs", false],
29
+ [ 3, "dec8", "dec8_swedish_ci", true ],
30
+ [ 4, "cp850", "cp850_general_ci", true ],
31
+ [ 5, "latin1", "latin1_german1_ci", false],
32
+ [ 6, "hp8", "hp8_english_ci", true ],
33
+ [ 7, "koi8r", "koi8r_general_ci", true ],
34
+ [ 8, "latin1", "latin1_swedish_ci", true ],
35
+ [ 9, "latin2", "latin2_general_ci", true ],
36
+ [ 10, "swe7", "swe7_swedish_ci", true ],
37
+ [ 11, "ascii", "ascii_general_ci", true ],
38
+ [ 12, "ujis", "ujis_japanese_ci", true ],
39
+ [ 13, "sjis", "sjis_japanese_ci", true ],
40
+ [ 14, "cp1251", "cp1251_bulgarian_ci", false],
41
+ [ 15, "latin1", "latin1_danish_ci", false],
42
+ [ 16, "hebrew", "hebrew_general_ci", true ],
43
+ [ 17, "filename", "filename", true ],
44
+ [ 18, "tis620", "tis620_thai_ci", true ],
45
+ [ 19, "euckr", "euckr_korean_ci", true ],
46
+ [ 20, "latin7", "latin7_estonian_cs", false],
47
+ [ 21, "latin2", "latin2_hungarian_ci", false],
48
+ [ 22, "koi8u", "koi8u_general_ci", true ],
49
+ [ 23, "cp1251", "cp1251_ukrainian_ci", false],
50
+ [ 24, "gb2312", "gb2312_chinese_ci", true ],
51
+ [ 25, "greek", "greek_general_ci", true ],
52
+ [ 26, "cp1250", "cp1250_general_ci", true ],
53
+ [ 27, "latin2", "latin2_croatian_ci", false],
54
+ [ 28, "gbk", "gbk_chinese_ci", true ],
55
+ [ 29, "cp1257", "cp1257_lithuanian_ci", false],
56
+ [ 30, "latin5", "latin5_turkish_ci", true ],
57
+ [ 31, "latin1", "latin1_german2_ci", false],
58
+ [ 32, "armscii8", "armscii8_general_ci", true ],
59
+ [ 33, "utf8", "utf8_general_ci", true ],
60
+ [ 33, "utf8mb3", "utf8mb3_general_ci", true ],
61
+ [ 34, "cp1250", "cp1250_czech_cs", false],
62
+ [ 35, "ucs2", "ucs2_general_ci", true ],
63
+ [ 36, "cp866", "cp866_general_ci", true ],
64
+ [ 37, "keybcs2", "keybcs2_general_ci", true ],
65
+ [ 38, "macce", "macce_general_ci", true ],
66
+ [ 39, "macroman", "macroman_general_ci", true ],
67
+ [ 40, "cp852", "cp852_general_ci", true ],
68
+ [ 41, "latin7", "latin7_general_ci", true ],
69
+ [ 42, "latin7", "latin7_general_cs", false],
70
+ [ 43, "macce", "macce_bin", false],
71
+ [ 44, "cp1250", "cp1250_croatian_ci", false],
72
+ [ 45, "utf8mb4", "utf8mb4_general_ci", false],
73
+ [ 46, "utf8mb4", "utf8mb4_bin", false],
74
+ [ 47, "latin1", "latin1_bin", false],
75
+ [ 48, "latin1", "latin1_general_ci", false],
76
+ [ 49, "latin1", "latin1_general_cs", false],
77
+ [ 50, "cp1251", "cp1251_bin", false],
78
+ [ 51, "cp1251", "cp1251_general_ci", true ],
79
+ [ 52, "cp1251", "cp1251_general_cs", false],
80
+ [ 53, "macroman", "macroman_bin", false],
81
+ [ 54, "utf16", "utf16_general_ci", true ],
82
+ [ 55, "utf16", "utf16_bin", false],
83
+ [ 56, "utf16le", "utf16le_general_ci", true ],
84
+ [ 57, "cp1256", "cp1256_general_ci", true ],
85
+ [ 58, "cp1257", "cp1257_bin", false],
86
+ [ 59, "cp1257", "cp1257_general_ci", true ],
87
+ [ 60, "utf32", "utf32_general_ci", true ],
88
+ [ 61, "utf32", "utf32_bin", false],
89
+ [ 62, "utf16le", "utf16le_bin", false],
90
+ [ 63, "binary", "binary", true ],
91
+ [ 64, "armscii8", "armscii8_bin", false],
92
+ [ 65, "ascii", "ascii_bin", false],
93
+ [ 66, "cp1250", "cp1250_bin", false],
94
+ [ 67, "cp1256", "cp1256_bin", false],
95
+ [ 68, "cp866", "cp866_bin", false],
96
+ [ 69, "dec8", "dec8_bin", false],
97
+ [ 70, "greek", "greek_bin", false],
98
+ [ 71, "hebrew", "hebrew_bin", false],
99
+ [ 72, "hp8", "hp8_bin", false],
100
+ [ 73, "keybcs2", "keybcs2_bin", false],
101
+ [ 74, "koi8r", "koi8r_bin", false],
102
+ [ 75, "koi8u", "koi8u_bin", false],
103
+ [ 76, "utf8", "utf8_tolower_ci", false],
104
+ [ 76, "utf8mb3", "utf8mb3_tolower_ci", false],
105
+ [ 77, "latin2", "latin2_bin", false],
106
+ [ 78, "latin5", "latin5_bin", false],
107
+ [ 79, "latin7", "latin7_bin", false],
108
+ [ 80, "cp850", "cp850_bin", false],
109
+ [ 81, "cp852", "cp852_bin", false],
110
+ [ 82, "swe7", "swe7_bin", false],
111
+ [ 83, "utf8", "utf8_bin", false],
112
+ [ 83, "utf8mb3", "utf8mb3_bin", false],
113
+ [ 84, "big5", "big5_bin", false],
114
+ [ 85, "euckr", "euckr_bin", false],
115
+ [ 86, "gb2312", "gb2312_bin", false],
116
+ [ 87, "gbk", "gbk_bin", false],
117
+ [ 88, "sjis", "sjis_bin", false],
118
+ [ 89, "tis620", "tis620_bin", false],
119
+ [ 90, "ucs2", "ucs2_bin", false],
120
+ [ 91, "ujis", "ujis_bin", false],
121
+ [ 92, "geostd8", "geostd8_general_ci", true ],
122
+ [ 93, "geostd8", "geostd8_bin", false],
123
+ [ 94, "latin1", "latin1_spanish_ci", false],
124
+ [ 95, "cp932", "cp932_japanese_ci", true ],
125
+ [ 96, "cp932", "cp932_bin", false],
126
+ [ 97, "eucjpms", "eucjpms_japanese_ci", true ],
127
+ [ 98, "eucjpms", "eucjpms_bin", false],
128
+ [ 99, "cp1250", "cp1250_polish_ci", false],
129
+ [101, "utf16", "utf16_unicode_ci", false],
130
+ [102, "utf16", "utf16_icelandic_ci", false],
131
+ [103, "utf16", "utf16_latvian_ci", false],
132
+ [104, "utf16", "utf16_romanian_ci", false],
133
+ [105, "utf16", "utf16_slovenian_ci", false],
134
+ [106, "utf16", "utf16_polish_ci", false],
135
+ [107, "utf16", "utf16_estonian_ci", false],
136
+ [108, "utf16", "utf16_spanish_ci", false],
137
+ [109, "utf16", "utf16_swedish_ci", false],
138
+ [110, "utf16", "utf16_turkish_ci", false],
139
+ [111, "utf16", "utf16_czech_ci", false],
140
+ [112, "utf16", "utf16_danish_ci", false],
141
+ [113, "utf16", "utf16_lithuanian_ci", false],
142
+ [114, "utf16", "utf16_slovak_ci", false],
143
+ [115, "utf16", "utf16_spanish2_ci", false],
144
+ [116, "utf16", "utf16_roman_ci", false],
145
+ [117, "utf16", "utf16_persian_ci", false],
146
+ [118, "utf16", "utf16_esperanto_ci", false],
147
+ [119, "utf16", "utf16_hungarian_ci", false],
148
+ [120, "utf16", "utf16_sinhala_ci", false],
149
+ [121, "utf16", "utf16_german2_ci", false],
150
+ [122, "utf16", "utf16_croatian_ci", false],
151
+ [123, "utf16", "utf16_unicode_520_ci", false],
152
+ [124, "utf16", "utf16_vietnamese_ci", false],
153
+ [128, "ucs2", "ucs2_unicode_ci", false],
154
+ [129, "ucs2", "ucs2_icelandic_ci", false],
155
+ [130, "ucs2", "ucs2_latvian_ci", false],
156
+ [131, "ucs2", "ucs2_romanian_ci", false],
157
+ [132, "ucs2", "ucs2_slovenian_ci", false],
158
+ [133, "ucs2", "ucs2_polish_ci", false],
159
+ [134, "ucs2", "ucs2_estonian_ci", false],
160
+ [135, "ucs2", "ucs2_spanish_ci", false],
161
+ [136, "ucs2", "ucs2_swedish_ci", false],
162
+ [137, "ucs2", "ucs2_turkish_ci", false],
163
+ [138, "ucs2", "ucs2_czech_ci", false],
164
+ [139, "ucs2", "ucs2_danish_ci", false],
165
+ [140, "ucs2", "ucs2_lithuanian_ci", false],
166
+ [141, "ucs2", "ucs2_slovak_ci", false],
167
+ [142, "ucs2", "ucs2_spanish2_ci", false],
168
+ [143, "ucs2", "ucs2_roman_ci", false],
169
+ [144, "ucs2", "ucs2_persian_ci", false],
170
+ [145, "ucs2", "ucs2_esperanto_ci", false],
171
+ [146, "ucs2", "ucs2_hungarian_ci", false],
172
+ [147, "ucs2", "ucs2_sinhala_ci", false],
173
+ [148, "ucs2", "ucs2_german2_ci", false],
174
+ [149, "ucs2", "ucs2_croatian_ci", false],
175
+ [150, "ucs2", "ucs2_unicode_520_ci", false],
176
+ [151, "ucs2", "ucs2_vietnamese_ci", false],
177
+ [159, "ucs2", "ucs2_general_mysql500_ci", false],
178
+ [160, "utf32", "utf32_unicode_ci", false],
179
+ [161, "utf32", "utf32_icelandic_ci", false],
180
+ [162, "utf32", "utf32_latvian_ci", false],
181
+ [163, "utf32", "utf32_romanian_ci", false],
182
+ [164, "utf32", "utf32_slovenian_ci", false],
183
+ [165, "utf32", "utf32_polish_ci", false],
184
+ [166, "utf32", "utf32_estonian_ci", false],
185
+ [167, "utf32", "utf32_spanish_ci", false],
186
+ [168, "utf32", "utf32_swedish_ci", false],
187
+ [169, "utf32", "utf32_turkish_ci", false],
188
+ [170, "utf32", "utf32_czech_ci", false],
189
+ [171, "utf32", "utf32_danish_ci", false],
190
+ [172, "utf32", "utf32_lithuanian_ci", false],
191
+ [173, "utf32", "utf32_slovak_ci", false],
192
+ [174, "utf32", "utf32_spanish2_ci", false],
193
+ [175, "utf32", "utf32_roman_ci", false],
194
+ [176, "utf32", "utf32_persian_ci", false],
195
+ [177, "utf32", "utf32_esperanto_ci", false],
196
+ [178, "utf32", "utf32_hungarian_ci", false],
197
+ [179, "utf32", "utf32_sinhala_ci", false],
198
+ [180, "utf32", "utf32_german2_ci", false],
199
+ [181, "utf32", "utf32_croatian_ci", false],
200
+ [182, "utf32", "utf32_unicode_520_ci", false],
201
+ [183, "utf32", "utf32_vietnamese_ci", false],
202
+ [192, "utf8", "utf8_unicode_ci", false],
203
+ [193, "utf8", "utf8_icelandic_ci", false],
204
+ [194, "utf8", "utf8_latvian_ci", false],
205
+ [195, "utf8", "utf8_romanian_ci", false],
206
+ [196, "utf8", "utf8_slovenian_ci", false],
207
+ [197, "utf8", "utf8_polish_ci", false],
208
+ [198, "utf8", "utf8_estonian_ci", false],
209
+ [199, "utf8", "utf8_spanish_ci", false],
210
+ [200, "utf8", "utf8_swedish_ci", false],
211
+ [201, "utf8", "utf8_turkish_ci", false],
212
+ [202, "utf8", "utf8_czech_ci", false],
213
+ [203, "utf8", "utf8_danish_ci", false],
214
+ [204, "utf8", "utf8_lithuanian_ci", false],
215
+ [205, "utf8", "utf8_slovak_ci", false],
216
+ [206, "utf8", "utf8_spanish2_ci", false],
217
+ [207, "utf8", "utf8_roman_ci", false],
218
+ [208, "utf8", "utf8_persian_ci", false],
219
+ [209, "utf8", "utf8_esperanto_ci", false],
220
+ [210, "utf8", "utf8_hungarian_ci", false],
221
+ [211, "utf8", "utf8_sinhala_ci", false],
222
+ [212, "utf8", "utf8_german2_ci", false],
223
+ [213, "utf8", "utf8_croatian_ci", false],
224
+ [214, "utf8", "utf8_unicode_520_ci", false],
225
+ [215, "utf8", "utf8_vietnamese_ci", false],
226
+ [223, "utf8", "utf8_general_mysql500_ci", false],
227
+ [192, "utf8mb3", "utf8mb3_unicode_ci", false],
228
+ [193, "utf8mb3", "utf8mb3_icelandic_ci", false],
229
+ [194, "utf8mb3", "utf8mb3_latvian_ci", false],
230
+ [195, "utf8mb3", "utf8mb3_romanian_ci", false],
231
+ [196, "utf8mb3", "utf8mb3_slovenian_ci", false],
232
+ [197, "utf8mb3", "utf8mb3_polish_ci", false],
233
+ [198, "utf8mb3", "utf8mb3_estonian_ci", false],
234
+ [199, "utf8mb3", "utf8mb3_spanish_ci", false],
235
+ [200, "utf8mb3", "utf8mb3_swedish_ci", false],
236
+ [201, "utf8mb3", "utf8mb3_turkish_ci", false],
237
+ [202, "utf8mb3", "utf8mb3_czech_ci", false],
238
+ [203, "utf8mb3", "utf8mb3_danish_ci", false],
239
+ [204, "utf8mb3", "utf8mb3_lithuanian_ci", false],
240
+ [205, "utf8mb3", "utf8mb3_slovak_ci", false],
241
+ [206, "utf8mb3", "utf8mb3_spanish2_ci", false],
242
+ [207, "utf8mb3", "utf8mb3_roman_ci", false],
243
+ [208, "utf8mb3", "utf8mb3_persian_ci", false],
244
+ [209, "utf8mb3", "utf8mb3_esperanto_ci", false],
245
+ [210, "utf8mb3", "utf8mb3_hungarian_ci", false],
246
+ [211, "utf8mb3", "utf8mb3_sinhala_ci", false],
247
+ [212, "utf8mb3", "utf8mb3_german2_ci", false],
248
+ [213, "utf8mb3", "utf8mb3_croatian_ci", false],
249
+ [214, "utf8mb3", "utf8mb3_unicode_520_ci", false],
250
+ [215, "utf8mb3", "utf8mb3_vietnamese_ci", false],
251
+ [223, "utf8mb3", "utf8mb3_general_mysql500_ci", false],
252
+ [224, "utf8mb4", "utf8mb4_unicode_ci", false],
253
+ [225, "utf8mb4", "utf8mb4_icelandic_ci", false],
254
+ [226, "utf8mb4", "utf8mb4_latvian_ci", false],
255
+ [227, "utf8mb4", "utf8mb4_romanian_ci", false],
256
+ [228, "utf8mb4", "utf8mb4_slovenian_ci", false],
257
+ [229, "utf8mb4", "utf8mb4_polish_ci", false],
258
+ [230, "utf8mb4", "utf8mb4_estonian_ci", false],
259
+ [231, "utf8mb4", "utf8mb4_spanish_ci", false],
260
+ [232, "utf8mb4", "utf8mb4_swedish_ci", false],
261
+ [233, "utf8mb4", "utf8mb4_turkish_ci", false],
262
+ [234, "utf8mb4", "utf8mb4_czech_ci", false],
263
+ [235, "utf8mb4", "utf8mb4_danish_ci", false],
264
+ [236, "utf8mb4", "utf8mb4_lithuanian_ci", false],
265
+ [237, "utf8mb4", "utf8mb4_slovak_ci", false],
266
+ [238, "utf8mb4", "utf8mb4_spanish2_ci", false],
267
+ [239, "utf8mb4", "utf8mb4_roman_ci", false],
268
+ [240, "utf8mb4", "utf8mb4_persian_ci", false],
269
+ [241, "utf8mb4", "utf8mb4_esperanto_ci", false],
270
+ [242, "utf8mb4", "utf8mb4_hungarian_ci", false],
271
+ [243, "utf8mb4", "utf8mb4_sinhala_ci", false],
272
+ [244, "utf8mb4", "utf8mb4_german2_ci", false],
273
+ [245, "utf8mb4", "utf8mb4_croatian_ci", false],
274
+ [246, "utf8mb4", "utf8mb4_unicode_520_ci", false],
275
+ [247, "utf8mb4", "utf8mb4_vietnamese_ci", false],
276
+ [248, "gb18030", "gb18030_chinese_ci", true ],
277
+ [249, "gb18030", "gb18030_bin", false],
278
+ [250, "gb18030", "gb18030_unicode_520_ci", false],
279
+ [254, "utf8", "utf8mb3_general_cs", false],
280
+ [254, "utf8mb3", "utf8mb3_general_cs", false],
281
+ [255, "utf8mb4", "utf8mb4_0900_ai_ci", true ],
282
+ [256, "utf8mb4", "utf8mb4_de_pb_0900_ai_ci", false],
283
+ [257, "utf8mb4", "utf8mb4_is_0900_ai_ci", false],
284
+ [258, "utf8mb4", "utf8mb4_lv_0900_ai_ci", false],
285
+ [259, "utf8mb4", "utf8mb4_ro_0900_ai_ci", false],
286
+ [260, "utf8mb4", "utf8mb4_sl_0900_ai_ci", false],
287
+ [261, "utf8mb4", "utf8mb4_pl_0900_ai_ci", false],
288
+ [262, "utf8mb4", "utf8mb4_et_0900_ai_ci", false],
289
+ [263, "utf8mb4", "utf8mb4_es_0900_ai_ci", false],
290
+ [264, "utf8mb4", "utf8mb4_sv_0900_ai_ci", false],
291
+ [265, "utf8mb4", "utf8mb4_tr_0900_ai_ci", false],
292
+ [266, "utf8mb4", "utf8mb4_cs_0900_ai_ci", false],
293
+ [267, "utf8mb4", "utf8mb4_da_0900_ai_ci", false],
294
+ [268, "utf8mb4", "utf8mb4_lt_0900_ai_ci", false],
295
+ [269, "utf8mb4", "utf8mb4_sk_0900_ai_ci", false],
296
+ [270, "utf8mb4", "utf8mb4_es_trad_0900_ai_ci", false],
297
+ [271, "utf8mb4", "utf8mb4_la_0900_ai_ci", false],
298
+ [273, "utf8mb4", "utf8mb4_eo_0900_ai_ci", false],
299
+ [274, "utf8mb4", "utf8mb4_hu_0900_ai_ci", false],
300
+ [275, "utf8mb4", "utf8mb4_hr_0900_ai_ci", false],
301
+ [277, "utf8mb4", "utf8mb4_vi_0900_ai_ci", false],
302
+ [278, "utf8mb4", "utf8mb4_0900_as_cs", false],
303
+ [279, "utf8mb4", "utf8mb4_de_pb_0900_as_cs", false],
304
+ [280, "utf8mb4", "utf8mb4_is_0900_as_cs", false],
305
+ [281, "utf8mb4", "utf8mb4_lv_0900_as_cs", false],
306
+ [282, "utf8mb4", "utf8mb4_ro_0900_as_cs", false],
307
+ [283, "utf8mb4", "utf8mb4_sl_0900_as_cs", false],
308
+ [284, "utf8mb4", "utf8mb4_pl_0900_as_cs", false],
309
+ [285, "utf8mb4", "utf8mb4_et_0900_as_cs", false],
310
+ [286, "utf8mb4", "utf8mb4_es_0900_as_cs", false],
311
+ [287, "utf8mb4", "utf8mb4_sv_0900_as_cs", false],
312
+ [288, "utf8mb4", "utf8mb4_tr_0900_as_cs", false],
313
+ [289, "utf8mb4", "utf8mb4_cs_0900_as_cs", false],
314
+ [290, "utf8mb4", "utf8mb4_da_0900_as_cs", false],
315
+ [291, "utf8mb4", "utf8mb4_lt_0900_as_cs", false],
316
+ [292, "utf8mb4", "utf8mb4_sk_0900_as_cs", false],
317
+ [293, "utf8mb4", "utf8mb4_es_trad_0900_as_cs", false],
318
+ [294, "utf8mb4", "utf8mb4_la_0900_as_cs", false],
319
+ [296, "utf8mb4", "utf8mb4_eo_0900_as_cs", false],
320
+ [297, "utf8mb4", "utf8mb4_hu_0900_as_cs", false],
321
+ [298, "utf8mb4", "utf8mb4_hr_0900_as_cs", false],
322
+ [300, "utf8mb4", "utf8mb4_vi_0900_as_cs", false],
323
+ [303, "utf8mb4", "utf8mb4_ja_0900_as_cs", false],
324
+ [304, "utf8mb4", "utf8mb4_ja_0900_as_cs_ks", false],
325
+ [305, "utf8mb4", "utf8mb4_0900_as_ci", false],
326
+ [306, "utf8mb4", "utf8mb4_ru_0900_ai_ci", false],
327
+ [307, "utf8mb4", "utf8mb4_ru_0900_as_cs", false],
328
+ [308, "utf8mb4", "utf8mb4_zh_0900_as_cs", false],
329
+ [309, "utf8mb4", "utf8mb4_0900_bin", false],
188
330
  ]
189
331
 
190
332
  # @private
@@ -195,7 +337,6 @@ class Mysql
195
337
  CHARSET_DEFAULT = {}
196
338
  CHARSETS.each do |number, csname, clname, default|
197
339
  cs = Charset.new number, csname, clname
198
- cs.unsafe = true if UNSAFE_CHARSET.include? csname
199
340
  NUMBER_TO_CHARSET[number] = cs
200
341
  COLLATION_TO_CHARSET[clname] = cs
201
342
  CHARSET_DEFAULT[csname] = cs if default
@@ -221,105 +362,87 @@ class Mysql
221
362
  ret
222
363
  end
223
364
 
224
- if defined? Encoding
225
-
226
- # @private
227
- # MySQL Charset -> Ruby's Encodeing
228
- CHARSET_ENCODING = {
229
- "armscii8" => nil,
230
- "ascii" => Encoding::US_ASCII,
231
- "big5" => Encoding::Big5,
232
- "binary" => Encoding::ASCII_8BIT,
233
- "cp1250" => Encoding::Windows_1250,
234
- "cp1251" => Encoding::Windows_1251,
235
- "cp1256" => Encoding::Windows_1256,
236
- "cp1257" => Encoding::Windows_1257,
237
- "cp850" => Encoding::CP850,
238
- "cp852" => Encoding::CP852,
239
- "cp866" => Encoding::IBM866,
240
- "cp932" => Encoding::Windows_31J,
241
- "dec8" => nil,
242
- "eucjpms" => Encoding::EucJP_ms,
243
- "euckr" => Encoding::EUC_KR,
244
- "gb2312" => Encoding::EUC_CN,
245
- "gbk" => Encoding::GBK,
246
- "geostd8" => nil,
247
- "greek" => Encoding::ISO_8859_7,
248
- "hebrew" => Encoding::ISO_8859_8,
249
- "hp8" => nil,
250
- "keybcs2" => nil,
251
- "koi8r" => Encoding::KOI8_R,
252
- "koi8u" => Encoding::KOI8_U,
253
- "latin1" => Encoding::ISO_8859_1,
254
- "latin2" => Encoding::ISO_8859_2,
255
- "latin5" => Encoding::ISO_8859_9,
256
- "latin7" => Encoding::ISO_8859_13,
257
- "macce" => Encoding::MacCentEuro,
258
- "macroman" => Encoding::MacRoman,
259
- "sjis" => Encoding::SHIFT_JIS,
260
- "swe7" => nil,
261
- "tis620" => Encoding::TIS_620,
262
- "ucs2" => Encoding::UTF_16BE,
263
- "ujis" => Encoding::EucJP_ms,
264
- "utf8" => Encoding::UTF_8,
265
- "utf8mb4" => Encoding::UTF_8,
266
- }
267
-
268
- # @private
269
- # @param [String] value
270
- # @return [String]
271
- def self.to_binary(value)
272
- value.force_encoding Encoding::ASCII_8BIT
273
- end
274
-
275
- # @private
276
- # convert raw to encoding and convert to Encoding.default_internal
277
- # @param [String] raw
278
- # @param [Encoding] encoding
279
- # @return [String] result
280
- def self.convert_encoding(raw, encoding)
281
- raw.force_encoding(encoding).encode
282
- end
283
-
284
- # @private
285
- # retrun corresponding Ruby encoding
286
- # @return [Encoding] encoding
287
- def encoding
288
- enc = CHARSET_ENCODING[@name.downcase]
289
- raise Mysql::ClientError, "unsupported charset: #{@name}" unless enc
290
- enc
291
- end
292
-
293
- # @private
294
- # convert encoding to corrensponding to MySQL charset
295
- # @param [String] value
296
- # @return [String]
297
- def convert(value)
298
- if value.is_a? String and value.encoding != Encoding::ASCII_8BIT
299
- value = value.encode encoding
300
- end
301
- value
302
- end
303
-
304
- else
305
- # for Ruby 1.8
365
+ # @private
366
+ # MySQL Charset -> Ruby's Encoding
367
+ CHARSET_ENCODING = {
368
+ "armscii8" => nil,
369
+ "ascii" => Encoding::US_ASCII,
370
+ "big5" => Encoding::Big5,
371
+ "binary" => Encoding::ASCII_8BIT,
372
+ "cp1250" => Encoding::Windows_1250,
373
+ "cp1251" => Encoding::Windows_1251,
374
+ "cp1256" => Encoding::Windows_1256,
375
+ "cp1257" => Encoding::Windows_1257,
376
+ "cp850" => Encoding::CP850,
377
+ "cp852" => Encoding::CP852,
378
+ "cp866" => Encoding::IBM866,
379
+ "cp932" => Encoding::Windows_31J,
380
+ "dec8" => nil,
381
+ "eucjpms" => Encoding::EucJP_ms,
382
+ "euckr" => Encoding::EUC_KR,
383
+ "gb18030" => Encoding::GB18030,
384
+ "gb2312" => Encoding::EUC_CN,
385
+ "gbk" => Encoding::GBK,
386
+ "geostd8" => nil,
387
+ "greek" => Encoding::ISO_8859_7,
388
+ "hebrew" => Encoding::ISO_8859_8,
389
+ "hp8" => nil,
390
+ "keybcs2" => nil,
391
+ "koi8r" => Encoding::KOI8_R,
392
+ "koi8u" => Encoding::KOI8_U,
393
+ "latin1" => Encoding::ISO_8859_1,
394
+ "latin2" => Encoding::ISO_8859_2,
395
+ "latin5" => Encoding::ISO_8859_9,
396
+ "latin7" => Encoding::ISO_8859_13,
397
+ "macce" => Encoding::MacCentEuro,
398
+ "macroman" => Encoding::MacRoman,
399
+ "sjis" => Encoding::SHIFT_JIS,
400
+ "swe7" => nil,
401
+ "tis620" => Encoding::TIS_620,
402
+ "ucs2" => Encoding::UTF_16BE,
403
+ "ujis" => Encoding::EucJP_ms,
404
+ "utf16" => Encoding::UTF_16BE,
405
+ "utf16le" => Encoding::UTF_16LE,
406
+ "utf32" => Encoding::UTF_32BE,
407
+ "utf8" => Encoding::UTF_8,
408
+ "utf8mb3" => Encoding::UTF_8,
409
+ "utf8mb4" => Encoding::UTF_8,
410
+ }
306
411
 
307
- def self.to_binary(value)
308
- value
309
- end
412
+ # @private
413
+ # @param [String] value
414
+ # @return [String]
415
+ def self.to_binary(value)
416
+ value.force_encoding Encoding::ASCII_8BIT
417
+ end
310
418
 
311
- def self.convert_encoding(raw, encoding)
312
- raw
313
- end
419
+ # @private
420
+ # convert raw to encoding and convert to Encoding.default_internal
421
+ # @param [String] raw
422
+ # @param [Encoding] encoding
423
+ # @return [String] result
424
+ def self.convert_encoding(raw, encoding)
425
+ raw.force_encoding(encoding).encode
426
+ end
314
427
 
315
- def encoding
316
- nil
317
- end
428
+ # @private
429
+ # retrun corresponding Ruby encoding
430
+ # @return [Encoding] encoding
431
+ def encoding
432
+ enc = CHARSET_ENCODING[@name.downcase]
433
+ raise Mysql::ClientError, "unsupported charset: #{@name}" unless enc
434
+ enc
435
+ end
318
436
 
319
- def convert(value)
320
- value
437
+ # @private
438
+ # convert encoding to corrensponding to MySQL charset
439
+ # @param [String] value
440
+ # @return [String]
441
+ def convert(value)
442
+ if value.is_a? String and value.encoding != Encoding::ASCII_8BIT
443
+ value = value.encode encoding
321
444
  end
322
-
445
+ value
323
446
  end
324
447
  end
325
448
  end