Ruby  1.9.3p484(2013-11-22revision43786)
japanese.c
Go to the documentation of this file.
1 /* autogenerated. */
2 /* src="transcode-tblgen.rb", len=28123, checksum=30477 */
3 /* src="japanese.trans", len=2261, checksum=31681 */
4 
5 #include "transcode_data.h"
6 
7 
8 
9 static const unsigned char
11 #define eucjp2sjis_8E_offsets 0
12 161, 254,
13  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
14  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
15  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
16  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
17  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
18  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
19 
20 #define eucjp2sjis_8F_A1toFE_offsets 96
21 161, 254,
22  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
23  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
24  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
25  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
26  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
27  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
28 
29 #define eucjp2sjis_offsets 192
30 0, 254,
31  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
32  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
33  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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4, 4, 4,
81 
82 };
83 static const unsigned int
85 #define eucjp2sjis_8E_infos WORDINDEX2INFO(0)
87 
88 #define eucjp2sjis_8E WORDINDEX2INFO(3)
91 
92 #define eucjp2sjis_8F_A1toFE_infos WORDINDEX2INFO(5)
93  INVALID, UNDEF,
94 
95 #define eucjp2sjis_8F_A1toFE WORDINDEX2INFO(7)
98 
99 #define eucjp2sjis_8F_infos WORDINDEX2INFO(9)
101 
102 #define eucjp2sjis_8F WORDINDEX2INFO(11)
103  eucjp2sjis_8F_A1toFE_offsets,
105 
106 #define eucjp2sjis_A1toFE_infos WORDINDEX2INFO(13)
107  INVALID, FUNso,
108 
109 #define eucjp2sjis_A1toFE WORDINDEX2INFO(15)
110  eucjp2sjis_8F_A1toFE_offsets,
112 
113 #define eucjp2sjis_infos WORDINDEX2INFO(17)
114  NOMAP, INVALID,
117 
118 #define eucjp2sjis WORDINDEX2INFO(22)
121 
122 #define sjis2eucjp_81to9F WORDINDEX2INFO(24)
124  eucjp2sjis_A1toFE_infos,
125 
126 #define sjis2eucjp_F0toFC WORDINDEX2INFO(26)
127  sjis2eucjp_81to9F_offsets,
128  eucjp2sjis_8F_A1toFE_infos,
129 
130 #define sjis2eucjp_infos WORDINDEX2INFO(28)
131  NOMAP, INVALID,
134 
135 #define sjis2eucjp WORDINDEX2INFO(33)
138 
139 };
140 #define TRANSCODE_TABLE_INFO japanese_byte_array, 895, japanese_word_array, 35, ((int)sizeof(unsigned int))
141 
142 
143 static ssize_t
144 fun_so_eucjp2sjis(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
145 {
146  if (s[0] == 0x8e) {
147  o[0] = s[1];
148  return 1;
149  }
150  else {
151  int h, m, l;
152  m = s[0] & 1;
153  h = (s[0]+m) >> 1;
154  h += s[0] < 0xdf ? 0x30 : 0x70;
155  l = s[1] - m * 94 - 3;
156  if (0x7f <= l)
157  l++;
158  o[0] = h;
159  o[1] = l;
160  return 2;
161  }
162 }
163 
164 static ssize_t
165 fun_so_sjis2eucjp(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
166 {
167  if (l == 1) {
168  o[0] = '\x8e';
169  o[1] = s[0];
170  return 2;
171  }
172  else {
173  int h, l;
174  h = s[0];
175  l = s[1];
176  if (0xe0 <= h)
177  h -= 64;
178  l += l < 0x80 ? 0x61 : 0x60;
179  h = h * 2 - 0x61;
180  if (0xfe < l) {
181  l -= 94;
182  h += 1;
183  }
184  o[0] = h;
185  o[1] = l;
186  return 2;
187  }
188 }
189 
190 static const rb_transcoder
192  "EUC-JP", "Shift_JIS", eucjp2sjis,
194  1, /* input_unit_length */
195  3, /* max_input */
196  2, /* max_output */
197  asciicompat_converter, /* asciicompat_type */
198  0, NULL, NULL, /* state_size, state_init, state_fini */
199  NULL, NULL, NULL, fun_so_eucjp2sjis
200 };
201 
202 static const rb_transcoder
204  "Shift_JIS", "EUC-JP", sjis2eucjp,
206  1, /* input_unit_length */
207  2, /* max_input */
208  2, /* max_output */
209  asciicompat_converter, /* asciicompat_type */
210  0, NULL, NULL, /* state_size, state_init, state_fini */
211  NULL, NULL, NULL, fun_so_sjis2eucjp
212 };
213 
214 void
216 {
219 }
220 
221