aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/mb/Unicode/UCS_to_SJIS.pl')
-rwxr-xr-xsrc/backend/utils/mb/Unicode/UCS_to_SJIS.pl123
1 files changed, 69 insertions, 54 deletions
diff --git a/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl b/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
index 510350e6b53..f93ca7af302 100755
--- a/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
+++ b/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
@@ -22,60 +22,68 @@ require "ucs2utf.pl";
# first generate UTF-8 --> SJIS table
$in_file = "CP932.TXT";
-$count = 0;
+$count = 0;
+
+open(FILE, $in_file) || die("cannot open $in_file");
-open( FILE, $in_file ) || die( "cannot open $in_file" );
-
-while( <FILE> ){
- chop;
- if( /^#/ ){
- next;
- }
- ( $c, $u, $rest ) = split;
- $ucs = hex($u);
- $code = hex($c);
- if( $code >= 0x80 && $ucs >= 0x0080 ){
- $utf = &ucs2utf($ucs);
- if((( $code >= 0xed40 )
- && ( $code <= 0xeefc ))
- || (( $code >= 0x8754 )
- &&( $code <= 0x875d ))
- || ( $code == 0x878a )
- || ( $code == 0x8782 )
- || ( $code == 0x8784 )
- || ( $code == 0xfa5b )
- || ( $code == 0xfa54 )
- || (( $code >= 0x8790 )
- && ( $code <= 0x8792 ))
- || (( $code >= 0x8795 )
- && ( $code <= 0x8797 ))
- || (( $code >= 0x879a )
- && ( $code <= 0x879c )))
- {
- printf STDERR "Warning: duplicate UTF8 : UCS=0x%04x SJIS=0x%04x\n",$ucs,$code;
- next;
- }
- $count++;
- $array{ $utf } = $code;
- }
+while (<FILE>)
+{
+ chop;
+ if (/^#/)
+ {
+ next;
+ }
+ ($c, $u, $rest) = split;
+ $ucs = hex($u);
+ $code = hex($c);
+ if ($code >= 0x80 && $ucs >= 0x0080)
+ {
+ $utf = &ucs2utf($ucs);
+ if ((($code >= 0xed40) && ($code <= 0xeefc))
+ || ( ($code >= 0x8754)
+ && ($code <= 0x875d))
+ || ($code == 0x878a)
+ || ($code == 0x8782)
+ || ($code == 0x8784)
+ || ($code == 0xfa5b)
+ || ($code == 0xfa54)
+ || ( ($code >= 0x8790)
+ && ($code <= 0x8792))
+ || ( ($code >= 0x8795)
+ && ($code <= 0x8797))
+ || ( ($code >= 0x879a)
+ && ($code <= 0x879c)))
+ {
+ printf STDERR
+ "Warning: duplicate UTF8 : UCS=0x%04x SJIS=0x%04x\n", $ucs,
+ $code;
+ next;
+ }
+ $count++;
+ $array{$utf} = $code;
+ }
}
-close( FILE );
+close(FILE);
#
# first, generate UTF8 --> SJIS table
#
$file = "utf8_to_sjis.map";
-open( FILE, "> $file" ) || die( "cannot open $file" );
+open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_utf_to_local ULmapSJIS[ $count ] = {\n";
-for $index ( sort {$a <=> $b} keys( %array ) ){
- $code = $array{ $index };
+for $index (sort { $a <=> $b } keys(%array))
+{
+ $code = $array{$index};
$count--;
- if( $count == 0 ){
+ if ($count == 0)
+ {
printf FILE " {0x%04x, 0x%04x}\n", $index, $code;
- } else {
+ }
+ else
+ {
printf FILE " {0x%04x, 0x%04x},\n", $index, $code;
}
}
@@ -87,37 +95,44 @@ close(FILE);
# then generate SJIS --> UTF8 table
#
-open( FILE, $in_file ) || die( "cannot open $in_file" );
+open(FILE, $in_file) || die("cannot open $in_file");
reset 'array';
$count = 0;
-while( <FILE> ){
+while (<FILE>)
+{
chop;
- if( /^#/ ){
+ if (/^#/)
+ {
next;
}
- ( $c, $u, $rest ) = split;
- $ucs = hex($u);
+ ($c, $u, $rest) = split;
+ $ucs = hex($u);
$code = hex($c);
- if( $code >= 0x80 && $ucs >= 0x0080 ){
+ if ($code >= 0x80 && $ucs >= 0x0080)
+ {
$utf = &ucs2utf($ucs);
$count++;
- $array{ $code } = $utf;
+ $array{$code} = $utf;
}
}
-close( FILE );
+close(FILE);
$file = "sjis_to_utf8.map";
-open( FILE, "> $file" ) || die( "cannot open $file" );
+open(FILE, "> $file") || die("cannot open $file");
print FILE "static pg_local_to_utf LUmapSJIS[ $count ] = {\n";
-for $index ( sort {$a <=> $b} keys( %array ) ){
- $utf = $array{ $index };
+for $index (sort { $a <=> $b } keys(%array))
+{
+ $utf = $array{$index};
$count--;
- if( $count == 0 ){
+ if ($count == 0)
+ {
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
- } else {
+ }
+ else
+ {
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;
}
}