1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| #! /usr/bin/perl
| #
| # Copyright (c) 2007-2026, PostgreSQL Global Development Group
| #
| # src/backend/utils/mb/Unicode/UCS_to_GB18030.pl
| #
| # Generate UTF-8 <--> UHC code conversion tables from
| # "windows-949-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
| # <a u="009A" b="81 30 83 36"/>
| # where the "u" field is the Unicode code point in hex,
| # and the "b" field is the hex byte sequence for UHC
|
| use strict;
| use warnings FATAL => 'all';
|
| use convutils;
|
| my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_UHC.pl';
|
| # Read the input
|
| my $in_file = "windows-949-2000.xml";
|
| open(my $in, '<', $in_file) || die("cannot open $in_file");
|
| my @mapping;
|
| while (<$in>)
| {
| next if (!m/<a u="([0-9A-F]+)" b="([0-9A-F ]+)"/);
| my ($u, $c) = ($1, $2);
| $c =~ s/ //g;
| my $ucs = hex($u);
| my $code = hex($c);
|
| next if ($code == 0x0080 || $code == 0x00FF);
|
| if ($code >= 0x80 && $ucs >= 0x0080)
| {
| push @mapping,
| {
| ucs => $ucs,
| code => $code,
| direction => BOTH,
| f => $in_file,
| l => $.
| };
| }
| }
| close($in);
|
| # One extra character that's not in the source file.
| push @mapping,
| {
| direction => BOTH,
| code => 0xa2e8,
| ucs => 0x327e,
| comment => 'CIRCLED HANGUL IEUNG U',
| f => $this_script,
| l => __LINE__
| };
|
| print_conversion_tables($this_script, "UHC", \@mapping);
|
|