Update copyright for 2022
[pgsql.git] / src / backend / utils / mb / Unicode / UCS_to_UHC.pl
blob43be22f5df93b35afa4cf0e441e9f3697b186b09
1 #! /usr/bin/perl
3 # Copyright (c) 2007-2022, PostgreSQL Global Development Group
5 # src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
7 # Generate UTF-8 <--> UHC code conversion tables from
8 # "windows-949-2000.xml", obtained from
9 # http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/
11 # The lines we care about in the source file look like
12 # <a u="009A" b="81 30 83 36"/>
13 # where the "u" field is the Unicode code point in hex,
14 # and the "b" field is the hex byte sequence for UHC
16 use strict;
17 use warnings;
19 use convutils;
21 my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_UHC.pl';
23 # Read the input
25 my $in_file = "windows-949-2000.xml";
27 open(my $in, '<', $in_file) || die("cannot open $in_file");
29 my @mapping;
31 while (<$in>)
33 next if (!m/<a u="([0-9A-F]+)" b="([0-9A-F ]+)"/);
34 my ($u, $c) = ($1, $2);
35 $c =~ s/ //g;
36 my $ucs = hex($u);
37 my $code = hex($c);
39 next if ($code == 0x0080 || $code == 0x00FF);
41 if ($code >= 0x80 && $ucs >= 0x0080)
43 push @mapping,
45 ucs => $ucs,
46 code => $code,
47 direction => BOTH,
48 f => $in_file,
49 l => $.
53 close($in);
55 # One extra character that's not in the source file.
56 push @mapping,
58 direction => BOTH,
59 code => 0xa2e8,
60 ucs => 0x327e,
61 comment => 'CIRCLED HANGUL IEUNG U',
62 f => $this_script,
63 l => __LINE__
66 print_conversion_tables($this_script, "UHC", \@mapping);