File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
src/backend/utils/mb/Unicode Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 11#
2- # $PostgreSQL: pgsql/src/backend/utils/mb/Unicode/ucs2utf.pl,v 1.2 2003/11/29 22:40:01 pgsql Exp $
3- # convert UCS-2 to UTF-8
2+ # Copyright (c) 2001-2007, PostgreSQL Global Development Group
3+ #
4+ # $PostgreSQL: pgsql/src/backend/utils/mb/Unicode/ucs2utf.pl,v 1.3 2007/03/23 13:51:30 ishii Exp $
5+ # convert UCS-4 to UTF-8
46#
57sub ucs2utf {
68 local($ ucs ) = @ _ ;
@@ -10,11 +12,16 @@ sub ucs2utf {
1012 $ utf = $ ucs ;
1113 } elsif ($ ucs > 0x007f && $ ucs <= 0x07ff ) {
1214 $ utf = (($ ucs & 0x003f ) | 0x80 ) | ((($ ucs >> 6 ) | 0xc0 ) << 8 );
13- } else {
15+ } elsif ( $ ucs > 0x07ff && $ ucs <= 0xffff ) {
1416 $ utf = ((($ ucs >> 12 ) | 0xe0 ) << 16 ) |
1517 (((($ ucs & 0x0fc0 ) >> 6 ) | 0x80 ) << 8 ) |
1618 (($ ucs & 0x003f ) | 0x80 );
17- }
19+ } else {
20+ $ utf = ((($ ucs >> 18 ) | 0xf0 ) << 24 ) |
21+ (((($ ucs & 0x3ffff ) >> 12 ) | 0x80 ) << 16 ) |
22+ (((($ ucs & 0x0fc0 ) >> 6 ) | 0x80 ) << 8 ) |
23+ (($ ucs & 0x003f ) | 0x80 );
24+ }
1825 return ($ utf );
1926}
20271 ;
You can’t perform that action at this time.
0 commit comments