#! /usr/bin/perl
#
# Copyright (c) 2007-2016, PostgreSQL Global Development Group
#
# src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
#
# Generate UTF-8 <--> GB18030 code conversion tables from
# "gb-18030-2000.xml", obtained from
# http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/
#
# The lines we care about in the source file look like
#
# where the "u" field is the Unicode code point in hex,
# and the "b" field is the hex byte sequence for GB18030
use strict;
require convutils;
# Read the input
my $in_file = "gb-18030-2000.xml";
open(my $in, '<', $in_file) || die("cannot open $in_file");
my @mapping;
while (<$in>)
{
next if (!m/= 0x80 && $ucs >= 0x0080)
{
push @mapping, {
ucs => $ucs,
code => $code,
direction => 'both'
}
}
}
close($in);
print_tables("GB18030", \@mapping);