Skip to content

Commit 0452760

Browse files
committed
more exhaustive locale mapper
1 parent fdc03d8 commit 0452760

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

sqlx-core/src/mssql/protocol/type_info.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,46 +117,52 @@ impl TypeInfo {
117117
// unwrap: impossible to unwrap here, collation will be set
118118
// The locale is a windows LCID (locale identifier), which maps to an encoding
119119
let lcid = self.collation.unwrap().locale;
120+
// see https://github.com/lovasoa/lcid-to-codepage
120121
Ok(match lcid {
121122
// Arabic locales
122-
0x0401 | 0x0801 | 0x0c01 | 0x1001 | 0x1401 | 0x1801 | 0x1c01 | 0x2001
123-
| 0x2401 | 0x2801 | 0x2c01 | 0x3001 | 0x3401 | 0x3801 | 0x3c01 | 0x4001 => {
124-
encoding_rs::WINDOWS_1256
125-
}
123+
0x0401 | 0x3801 | 0x3C01 | 0x1401 | 0x0C01 | 0x0801 | 0x2C01 | 0x3401 |
124+
0x3001 | 0x1001 | 0x1801 | 0x2001 | 0x4001 | 0x2801 | 0x1C01 | 0x2401 |
125+
0x0429 | 0x0492 | 0x0846 | 0x048C | 0x0859 | 0x0420 | 0x0820 | 0x045F |
126+
0x0480 => encoding_rs::WINDOWS_1256,
126127

127128
// Chinese locales
128-
0x0404 | 0x0c04 | 0x1404 | 0x30404 => encoding_rs::BIG5,
129-
0x0804 | 0x1004 | 0x20804 | 0x21004 => encoding_rs::GBK,
129+
0x0804 | 0x50804 | 0x20804 | 0x1004 | 0x51004 | 0x21004 => encoding_rs::GBK,
130+
0x0C04 | 0x40C04 | 0x1404 | 0x41404 | 0x21404 | 0x0404 | 0x30404 |
131+
0x40404 => encoding_rs::BIG5,
130132

131133
// Cyrillic locales
132-
0x0402 | 0x0419 | 0x0422 | 0x0423 | 0x0843 => encoding_rs::WINDOWS_1251,
134+
0x082C | 0x046D | 0x0423 | 0x0402 | 0x201A | 0x0440 | 0x042F | 0x0450 |
135+
0x0419 | 0x0819 | 0x0485 | 0x0428 | 0x0444 | 0x0422 | 0x0843 | 0x281A |
136+
0x1C1A | 0x301A => encoding_rs::WINDOWS_1251,
133137

134138
// Central European locales
135-
0x0405 | 0x041a | 0x041b | 0x0424 | 0x0415 => encoding_rs::WINDOWS_1250,
139+
0x141A | 0x0405 | 0x041A | 0x101A | 0x040E | 0x1040E | 0x0415 | 0x0418 |
140+
0x0818 | 0x041B | 0x0424 | 0x041C | 0x241A | 0x181A | 0x2C1A |
141+
0x0442 => encoding_rs::WINDOWS_1250,
136142

137143
// Baltic locales
138-
0x0425 | 0x0426 | 0x0427 => encoding_rs::WINDOWS_1257,
144+
0x0425 | 0x0427 | 0x0426 => encoding_rs::WINDOWS_1257,
139145

140146
// Greek
141147
0x0408 => encoding_rs::WINDOWS_1253,
142148

143149
// Hebrew
144-
0x040d => encoding_rs::WINDOWS_1255,
150+
0x040D => encoding_rs::WINDOWS_1255,
145151

146152
// Japanese
147-
0x0411 => encoding_rs::SHIFT_JIS,
153+
0x0411 | 0x40411 => encoding_rs::SHIFT_JIS,
148154

149155
// Korean
150156
0x0412 => encoding_rs::EUC_KR,
151157

152158
// Thai
153-
0x041e => encoding_rs::WINDOWS_874,
159+
0x041E => encoding_rs::WINDOWS_874,
154160

155161
// Turkish
156-
0x041f => encoding_rs::WINDOWS_1254,
162+
0x042C | 0x041F | 0x0443 => encoding_rs::WINDOWS_1254,
157163

158164
// Vietnamese
159-
0x042a => encoding_rs::WINDOWS_1258,
165+
0x042A => encoding_rs::WINDOWS_1258,
160166

161167
// Western European/US locales - default for unhandled LCIDs
162168
_ => encoding_rs::WINDOWS_1252,

0 commit comments

Comments
 (0)