3
# Copyright (c) 2001-2005, PostgreSQL Global Development Group
5
# $PostgreSQL: pgsql/src/backend/utils/mb/Unicode/UCS_to_WIN874.pl,v 1.5 2005-01-01 20:44:18 tgl Exp $
7
# Generate UTF-8 <--> WIN874 code conversion tables from
8
# map files provided by Unicode organization.
9
# Unfortunately it is prohibited by the organization
10
# to distribute the map files. So if you try to use this script,
11
# you have to obtain OLD5601.TXT from
12
# the organization's ftp site.
17
# # and Unicode name (not used in this script)
21
# first generate UTF-8 --> WIN949 table
23
$in_file = "CP874.TXT";
25
open( FILE, $in_file ) || die( "cannot open $in_file" );
32
( $c, $u, $rest ) = split;
35
if( $code >= 0x80 && $ucs >= 0x0080 ){
36
$utf = &ucs2utf($ucs);
37
if( $array{ $utf } ne "" ){
38
printf STDERR "Warning: duplicate unicode: %04x\n",$ucs;
43
$array{ $utf } = $code;
49
# first, generate UTF8 --> WIN874 table
52
$file = "utf8_to_win874.map";
53
open( FILE, "> $file" ) || die( "cannot open $file" );
54
print FILE "static pg_utf_to_local ULmapWIN874[ $count ] = {\n";
56
for $index ( sort {$a <=> $b} keys( %array ) ){
57
$code = $array{ $index };
60
printf FILE " {0x%04x, 0x%04x}\n", $index, $code;
62
printf FILE " {0x%04x, 0x%04x},\n", $index, $code;
70
# then generate WIN874 --> UTF8 table
74
open( FILE, $in_file ) || die( "cannot open $in_file" );
81
( $c, $u, $rest ) = split;
84
if( $code >= 0x80 && $ucs >= 0x0080 ){
85
$utf = &ucs2utf($ucs);
86
if( $array{ $code } ne "" ){
87
printf STDERR "Warning: duplicate code: %04x\n",$ucs;
92
$array{ $code } = $utf;
97
$file = "win874_to_utf8.map";
98
open( FILE, "> $file" ) || die( "cannot open $file" );
99
print FILE "static pg_local_to_utf LUmapWIN874[ $count ] = {\n";
100
for $index ( sort {$a <=> $b} keys( %array ) ){
101
$utf = $array{ $index };
104
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
106
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;