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

Commit9217dee

Browse files
committed
Fix psql's copy of utf2ucs() to match the backend's copy exactly;
in particular, propagate a fix in the test to see whether a UTF8 character haslength 4 bytes. This is likely of little real-world consequence because5-or-more-byte UTF8 sequences are not supported by Postgres nor seen anywherein the wild, but still we may as well get it right. Problem found by JosephAdams.Bug is aboriginal, so back-patch all the way.
1 parent1207827 commit9217dee

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

‎src/bin/psql/mbprint.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.12 2003/09/12 02:40:09 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.12.2.1 2010/08/16 00:07:00 tgl Exp $
77
*/
88

99
#include"postgres_fe.h"
@@ -172,28 +172,20 @@ utf2ucs(const unsigned char *c)
172172
if ((*c&0x80)==0)
173173
return (pg_wchar)c[0];
174174
elseif ((*c&0xe0)==0xc0)
175-
{
176175
return (pg_wchar) (((c[0]&0x1f) <<6) |
177176
(c[1]&0x3f));
178-
}
179177
elseif ((*c&0xf0)==0xe0)
180-
{
181178
return (pg_wchar) (((c[0]&0x0f) <<12) |
182179
((c[1]&0x3f) <<6) |
183180
(c[2]&0x3f));
184-
}
185-
elseif ((*c&0xf0)==0xf0)
186-
{
181+
elseif ((*c&0xf8)==0xf0)
187182
return (pg_wchar) (((c[0]&0x07) <<18) |
188183
((c[1]&0x3f) <<12) |
189184
((c[2]&0x3f) <<6) |
190185
(c[3]&0x3f));
191-
}
192186
else
193-
{
194187
/* that is an invalid code on purpose */
195188
return0xffffffff;
196-
}
197189
}
198190

199191
/* mb_utf_wcwidth : calculate column length for the utf8 string pwcs

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp