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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
| #! /usr/bin/perl
| #
| # Copyright (c) 2001-2026, PostgreSQL Global Development Group
| #
| # src/backend/utils/mb/Unicode/UCS_to_SJIS.pl
| #
| # Generate UTF-8 <=> SJIS code conversion radix tree Generate UTF-8
| # <=> SJIS code conversion radix tree Unfortunately it is prohibited
| # by the organization to distribute the map files. So if you try to
| # use this script, you have to obtain CP932.TXT from the organization's
| # ftp site.
|
| use strict;
| use warnings FATAL => 'all';
|
| use convutils;
|
| my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_SJIS.pl';
|
| my $mapping = read_source("CP932.TXT");
|
| # Drop these SJIS codes from the source for UTF8=>SJIS conversion
| my @reject_sjis = (
| 0xed40 .. 0xeefc, 0x8754 .. 0x875d, 0x878a, 0x8782,
| 0x8784, 0xfa5b, 0xfa54, 0x8790 .. 0x8792,
| 0x8795 .. 0x8797, 0x879a .. 0x879c);
|
| foreach my $i (@$mapping)
| {
| my $code = $i->{code};
| my $ucs = $i->{ucs};
|
| if (grep { $code == $_ } @reject_sjis)
| {
| $i->{direction} = TO_UNICODE;
| }
| }
|
| # Add these UTF8->SJIS pairs to the table.
| push @$mapping,
| ( {
| direction => FROM_UNICODE,
| ucs => 0x00a2,
| code => 0x8191,
| comment => '# CENT SIGN',
| f => $this_script,
| l => __LINE__
| },
| {
| direction => FROM_UNICODE,
| ucs => 0x00a3,
| code => 0x8192,
| comment => '# POUND SIGN',
| f => $this_script,
| l => __LINE__
| },
| {
| direction => FROM_UNICODE,
| ucs => 0x00a5,
| code => 0x5c,
| comment => '# YEN SIGN',
| f => $this_script,
| l => __LINE__
| },
| {
| direction => FROM_UNICODE,
| ucs => 0x00ac,
| code => 0x81ca,
| comment => '# NOT SIGN',
| f => $this_script,
| l => __LINE__
| },
| {
| direction => FROM_UNICODE,
| ucs => 0x2016,
| code => 0x8161,
| comment => '# DOUBLE VERTICAL LINE',
| f => $this_script,
| l => __LINE__
| },
| {
| direction => FROM_UNICODE,
| ucs => 0x203e,
| code => 0x7e,
| comment => '# OVERLINE',
| f => $this_script,
| l => __LINE__
| },
| {
| direction => FROM_UNICODE,
| ucs => 0x2212,
| code => 0x817c,
| comment => '# MINUS SIGN',
| f => $this_script,
| l => __LINE__
| },
| {
| direction => FROM_UNICODE,
| ucs => 0x301c,
| code => 0x8160,
| comment => '# WAVE DASH',
| f => $this_script,
| l => __LINE__
| });
|
| print_conversion_tables($this_script, "SJIS", $mapping);
|
|