3
# Copyright (c) 2001-2011, PostgreSQL Global Development Group
5
# src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl
7
# Generate UTF-8 <--> EUC_KR 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 --> EUC_KR table
23
$in_file = "KSX1001.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 UTF8: %04x\n",$ucs;
43
$array{ $utf } = ($code | 0x8080);
49
# first, generate UTF8 --> EUC_KR table
52
$file = "utf8_to_euc_kr.map";
53
open( FILE, "> $file" ) || die( "cannot open $file" );
54
print FILE "static pg_utf_to_local ULmapEUC_KR[ $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 EUC_JP --> 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;
93
$array{ $code } = $utf;
98
$file = "euc_kr_to_utf8.map";
99
open( FILE, "> $file" ) || die( "cannot open $file" );
100
print FILE "static pg_local_to_utf LUmapEUC_KR[ $count ] = {\n";
101
for $index ( sort {$a <=> $b} keys( %array ) ){
102
$utf = $array{ $index };
105
printf FILE " {0x%04x, 0x%04x}\n", $index, $utf;
107
printf FILE " {0x%04x, 0x%04x},\n", $index, $utf;