Debian Codegraph @

src/backend/utils/mb/Unicode/UCS_to_SJIS.pl

raw
1 #! /usr/bin/perl
2 #
3 # Copyright (c) 2001-2025, PostgreSQL Global Development Group
4 #
5 # src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
6 #
7 # Generate UTF-8 <=> SJIS code conversion radix tree Generate UTF-8
8 # <=> SJIS code conversion radix tree Unfortunately it is prohibited
9 # by the organization to distribute the map files. So if you try to
10 # use this script, you have to obtain CP932.TXT from the organization's
11 # ftp site.
12
13 use strict;
14 use warnings FATAL => 'all';
15
16 use convutils;
17
18 my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_SJIS.pl';
19
20 my $mapping = read_source("CP932.TXT");
21
22 # Drop these SJIS codes from the source for UTF8=>SJIS conversion
23 my @reject_sjis = (
24 0xed40 .. 0xeefc, 0x8754 .. 0x875d, 0x878a, 0x8782,
25 0x8784, 0xfa5b, 0xfa54, 0x8790 .. 0x8792,
26 0x8795 .. 0x8797, 0x879a .. 0x879c);
27
28 foreach my $i (@$mapping)
29 {
30 my $code = $i->{code};
31 my $ucs = $i->{ucs};
32
33 if (grep { $code == $_ } @reject_sjis)
34 {
35 $i->{direction} = TO_UNICODE;
36 }
37 }
38
39 # Add these UTF8->SJIS pairs to the table.
40 push @$mapping,
41 ( {
42 direction => FROM_UNICODE,
43 ucs => 0x00a2,
44 code => 0x8191,
45 comment => '# CENT SIGN',
46 f => $this_script,
47 l => __LINE__
48 },
49 {
50 direction => FROM_UNICODE,
51 ucs => 0x00a3,
52 code => 0x8192,
53 comment => '# POUND SIGN',
54 f => $this_script,
55 l => __LINE__
56 },
57 {
58 direction => FROM_UNICODE,
59 ucs => 0x00a5,
60 code => 0x5c,
61 comment => '# YEN SIGN',
62 f => $this_script,
63 l => __LINE__
64 },
65 {
66 direction => FROM_UNICODE,
67 ucs => 0x00ac,
68 code => 0x81ca,
69 comment => '# NOT SIGN',
70 f => $this_script,
71 l => __LINE__
72 },
73 {
74 direction => FROM_UNICODE,
75 ucs => 0x2016,
76 code => 0x8161,
77 comment => '# DOUBLE VERTICAL LINE',
78 f => $this_script,
79 l => __LINE__
80 },
81 {
82 direction => FROM_UNICODE,
83 ucs => 0x203e,
84 code => 0x7e,
85 comment => '# OVERLINE',
86 f => $this_script,
87 l => __LINE__
88 },
89 {
90 direction => FROM_UNICODE,
91 ucs => 0x2212,
92 code => 0x817c,
93 comment => '# MINUS SIGN',
94 f => $this_script,
95 l => __LINE__
96 },
97 {
98 direction => FROM_UNICODE,
99 ucs => 0x301c,
100 code => 0x8160,
101 comment => '# WAVE DASH',
102 f => $this_script,
103 l => __LINE__
104 });
105
106 print_conversion_tables($this_script, "SJIS", $mapping);