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