Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit804f6b8

Browse files
committed
Fix long standing Asian multibyte charsets bug.
See:Subject: [HACKERS] bugs with certain Asian multibyte charsetsFrom: Tatsuo Ishii <ishii@sraoss.co.jp>To: pgsql-hackers@postgresql.orgDate: Sat, 24 Dec 2005 18:25:33 +0900 (JST)for more details/
1 parent7d732f0 commit804f6b8

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

‎src/backend/utils/mb/wchar.c

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* conversion functions between pg_wchar and multibyte streams.
33
* Tatsuo Ishii
4-
* $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.47 2005/10/29 00:31:52 petere Exp $
4+
* $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.48 2005/12/24 09:35:36 ishii Exp $
55
*
66
* WIN1250 client encoding updated by Pavel Behal
77
*
@@ -58,34 +58,33 @@ pg_ascii_dsplen(const unsigned char *s)
5858
/*
5959
* EUC
6060
*/
61-
6261
staticintpg_euc2wchar_with_len
6362
(constunsignedchar*from,pg_wchar*to,intlen)
6463
{
6564
intcnt=0;
6665

6766
while (len>0&&*from)
6867
{
69-
if (*from==SS2&&len >=2)
68+
if (*from==SS2&&len >=2)/* JIS X 0201 (so called "1 byte KANA") */
7069
{
7170
from++;
72-
*to=0xff&*from++;
71+
*to=(SS2 <<8) |*from++;
7372
len-=2;
7473
}
75-
elseif (*from==SS3&&len >=3)
74+
elseif (*from==SS3&&len >=3)/* JIS X 0212 KANJI */
7675
{
7776
from++;
78-
*to=*from++ <<8;
79-
*to |=0x3f&*from++;
77+
*to=(SS3 <<16) | (*from++ <<8);
78+
*to |=*from++;
8079
len-=3;
8180
}
82-
elseif ((*from&0x80)&&len >=2)
81+
elseif ((*from&0x80)&&len >=2)/* JIS X 0208 KANJI */
8382
{
8483
*to=*from++ <<8;
8584
*to |=*from++;
8685
len-=2;
8786
}
88-
else
87+
else/* must be ASCII */
8988
{
9089
*to=*from++;
9190
len--;
@@ -183,6 +182,7 @@ pg_euckr_dsplen(const unsigned char *s)
183182

184183
/*
185184
* EUC_CN
185+
*
186186
*/
187187
staticintpg_euccn2wchar_with_len
188188
(constunsignedchar*from,pg_wchar*to,intlen)
@@ -191,21 +191,21 @@ static intpg_euccn2wchar_with_len
191191

192192
while (len>0&&*from)
193193
{
194-
if (*from==SS2&&len >=3)
194+
if (*from==SS2&&len >=3)/* code set 2 (unused?) */
195195
{
196196
from++;
197-
*to=0x3f00& (*from++ <<8);
198-
*to=*from++;
197+
*to=(SS2 <<16) | (*from++ <<8);
198+
*to|=*from++;
199199
len-=3;
200200
}
201-
elseif (*from==SS3&&len >=3)
201+
elseif (*from==SS3&&len >=3)/* code set 3 (unsed ?) */
202202
{
203203
from++;
204-
*to=*from++ <<8;
205-
*to |=0x3f&*from++;
204+
*to=(SS3 <<16) | (*from++ <<8);
205+
*to |=*from++;
206206
len-=3;
207207
}
208-
elseif ((*from&0x80)&&len >=2)
208+
elseif ((*from&0x80)&&len >=2)/* code set 1 */
209209
{
210210
*to=*from++ <<8;
211211
*to |=*from++;
@@ -249,6 +249,7 @@ pg_euccn_dsplen(const unsigned char *s)
249249

250250
/*
251251
* EUC_TW
252+
*
252253
*/
253254
staticintpg_euctw2wchar_with_len
254255
(constunsignedchar*from,pg_wchar*to,intlen)
@@ -257,22 +258,22 @@ static intpg_euctw2wchar_with_len
257258

258259
while (len>0&&*from)
259260
{
260-
if (*from==SS2&&len >=4)
261+
if (*from==SS2&&len >=4)/* code set 2 */
261262
{
262263
from++;
263-
*to=*from++ <<16;
264+
*to=(SS2 <<24) | (*from++ <<16);
264265
*to |=*from++ <<8;
265266
*to |=*from++;
266267
len-=4;
267268
}
268-
elseif (*from==SS3&&len >=3)
269+
elseif (*from==SS3&&len >=3)/* code set 3 (unused?) */
269270
{
270271
from++;
271-
*to=*from++ <<8;
272-
*to |=0x3f&*from++;
272+
*to=(SS3 <<16) | (*from++ <<8);
273+
*to |=*from++;
273274
len-=3;
274275
}
275-
elseif ((*from&0x80)&&len >=2)
276+
elseif ((*from&0x80)&&len >=2)/* code set 2 */
276277
{
277278
*to=*from++ <<8;
278279
*to |=*from++;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp