2007-03-25 13:56:04 +02:00
|
|
|
#! /usr/bin/perl
|
|
|
|
#
|
2016-01-02 19:33:40 +01:00
|
|
|
# Copyright (c) 2007-2016, PostgreSQL Global Development Group
|
2007-03-25 13:56:04 +02:00
|
|
|
#
|
2010-09-20 22:08:53 +02:00
|
|
|
# src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl
|
2007-03-25 13:56:04 +02:00
|
|
|
#
|
|
|
|
# Generate UTF-8 <--> EUC_JIS_2004 code conversion tables from
|
|
|
|
# "euc-jis-2004-std.txt" (http://x0213.org)
|
|
|
|
|
2016-11-30 13:54:02 +01:00
|
|
|
require "convutils.pm";
|
2007-03-25 13:56:04 +02:00
|
|
|
|
|
|
|
# first generate UTF-8 --> EUC_JIS_2004 table
|
|
|
|
|
|
|
|
$in_file = "euc-jis-2004-std.txt";
|
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
open(FILE, $in_file) || die("cannot open $in_file");
|
2007-03-25 13:56:04 +02:00
|
|
|
|
2016-11-30 13:54:02 +01:00
|
|
|
my @all;
|
2007-03-25 13:56:04 +02:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
while ($line = <FILE>)
|
|
|
|
{
|
|
|
|
if ($line =~ /^0x(.*)[ \t]*U\+(.*)\+(.*)[ \t]*#(.*)$/)
|
|
|
|
{
|
|
|
|
$c = $1;
|
|
|
|
$u1 = $2;
|
|
|
|
$u2 = $3;
|
|
|
|
$rest = "U+" . $u1 . "+" . $u2 . $4;
|
|
|
|
$code = hex($c);
|
2016-11-30 13:54:02 +01:00
|
|
|
$ucs1 = hex($u1);
|
|
|
|
$ucs2 = hex($u2);
|
|
|
|
|
|
|
|
push @all, { direction => 'both',
|
|
|
|
ucs => $ucs1,
|
|
|
|
ucs_second => $ucs2,
|
|
|
|
code => $code,
|
|
|
|
comment => $rest };
|
2007-03-25 13:56:04 +02:00
|
|
|
next;
|
2012-07-05 03:47:49 +02:00
|
|
|
}
|
|
|
|
elsif ($line =~ /^0x(.*)[ \t]*U\+(.*)[ \t]*#(.*)$/)
|
|
|
|
{
|
|
|
|
$c = $1;
|
|
|
|
$u = $2;
|
2007-03-25 13:56:04 +02:00
|
|
|
$rest = "U+" . $u . $3;
|
2012-07-05 03:47:49 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-25 13:56:04 +02:00
|
|
|
next;
|
|
|
|
}
|
2010-11-23 21:27:50 +01:00
|
|
|
|
2012-07-05 03:47:49 +02:00
|
|
|
$ucs = hex($u);
|
2007-03-25 13:56:04 +02:00
|
|
|
$code = hex($c);
|
|
|
|
|
2016-11-30 13:54:02 +01:00
|
|
|
next if ($code < 0x80 && $ucs < 0x80);
|
2007-03-25 13:56:04 +02:00
|
|
|
|
2016-11-30 13:54:02 +01:00
|
|
|
push @all, { direction => 'both', ucs => $ucs, code => $code, comment => $rest };
|
2007-03-25 13:56:04 +02:00
|
|
|
}
|
|
|
|
close(FILE);
|
|
|
|
|
2016-11-30 13:54:02 +01:00
|
|
|
print_tables("EUC_JIS_2004", \@all, 1);
|