Skip to content

Commit 90a06db

Browse files
committed
Fix broken GB18030 <--> UTF-8 conversion map
1 parent 5eb6de5 commit 90a06db

File tree

3 files changed

+126746
-126986
lines changed

3 files changed

+126746
-126986
lines changed

src/backend/utils/mb/Unicode/UCS_to_GB18030.pl

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Copyright 2002 by Bill Huang
44
#
5-
# $Id: UCS_to_GB18030.pl,v 1.1 2002/06/13 08:28:55 ishii Exp $
5+
# $Id: UCS_to_GB18030.pl,v 1.2 2002/11/12 11:33:40 ishii Exp $
66
#
77
# Generate UTF-8 <--> GB18030 code conversion tables from
88
# map files provided by Unicode organization.
@@ -30,10 +30,18 @@
3030
next;
3131
}
3232
( $u, $c, $rest ) = split;
33-
$utf = hex($u);
33+
$ucs = hex($u);
3434
$code = hex($c);
35-
$count++;
36-
$array{ $utf } = ($code);
35+
if( $code >= 0x80 && $ucs >= 0x0080 ){
36+
$utf = &ucs2utf($ucs);
37+
if( $array{ $utf } ne "" ){
38+
printf STDERR "Warning: duplicate unicode: %04x\n",$ucs;
39+
next;
40+
}
41+
$count++;
42+
43+
$array{ $utf } = $code;
44+
}
3745
}
3846
close( FILE );
3947

@@ -70,11 +78,19 @@
7078
if( /^#/ ){
7179
next;
7280
}
73-
( $u, $c, $rest ) = split;
74-
$utf = hex($u);
81+
( $c, $u, $rest ) = split;
82+
$ucs = hex($u);
7583
$code = hex($c);
76-
$count++;
77-
$array{ $code } = $utf;
84+
if( $code >= 0x80 && $ucs >= 0x0080 ){
85+
$utf = &ucs2utf($ucs);
86+
if( $array{ $code } ne "" ){
87+
printf STDERR "Warning: duplicate code: %04x\n",$ucs;
88+
next;
89+
}
90+
$count++;
91+
92+
$array{ $code } = $utf;
93+
}
7894
}
7995
close( FILE );
8096

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy