summaryrefslogtreecommitdiff
path: root/jni/ruby/enc/trans/japanese.c
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-16 18:49:26 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-30 00:39:06 +0900
commitfcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch)
tree64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/enc/trans/japanese.c
Fresh start
Diffstat (limited to 'jni/ruby/enc/trans/japanese.c')
-rw-r--r--jni/ruby/enc/trans/japanese.c219
1 files changed, 219 insertions, 0 deletions
diff --git a/jni/ruby/enc/trans/japanese.c b/jni/ruby/enc/trans/japanese.c
new file mode 100644
index 0000000..452ebc4
--- /dev/null
+++ b/jni/ruby/enc/trans/japanese.c
@@ -0,0 +1,219 @@
+/* autogenerated. */
+/* src="transcode-tblgen.rb", len=28509, checksum=52888 */
+/* src="japanese.trans", len=2257, checksum=31099 */
+
+#include "transcode_data.h"
+
+
+
+static const unsigned char
+japanese_byte_array[895] = {
+#define eucjp2sjis_8E_offsets 0
+161, 254,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+
+#define eucjp2sjis_8F_A1toFE_offsets 96
+161, 254,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+
+};
+static const unsigned int
+japanese_word_array[35] = {
+#define eucjp2sjis_8E_infos WORDINDEX2INFO(0)
+ INVALID, FUNso, UNDEF,
+
+#define eucjp2sjis_8E WORDINDEX2INFO(3)
+ eucjp2sjis_8E_offsets,
+ eucjp2sjis_8E_infos,
+
+#define eucjp2sjis_8F_A1toFE_infos WORDINDEX2INFO(5)
+ INVALID, UNDEF,
+
+#define eucjp2sjis_8F_A1toFE WORDINDEX2INFO(7)
+ eucjp2sjis_8F_A1toFE_offsets,
+ eucjp2sjis_8F_A1toFE_infos,
+
+#define eucjp2sjis_8F_infos WORDINDEX2INFO(9)
+ INVALID, eucjp2sjis_8F_A1toFE,
+
+#define eucjp2sjis_8F WORDINDEX2INFO(11)
+ eucjp2sjis_8F_A1toFE_offsets,
+ eucjp2sjis_8F_infos,
+
+#define eucjp2sjis_A1toFE_infos WORDINDEX2INFO(13)
+ INVALID, FUNso,
+
+#define eucjp2sjis_A1toFE WORDINDEX2INFO(15)
+ eucjp2sjis_8F_A1toFE_offsets,
+ eucjp2sjis_A1toFE_infos,
+
+#define eucjp2sjis_infos WORDINDEX2INFO(17)
+ NOMAP, INVALID,
+ eucjp2sjis_8E, eucjp2sjis_8F,
+ eucjp2sjis_A1toFE,
+
+#define eucjp2sjis WORDINDEX2INFO(22)
+ eucjp2sjis_offsets,
+ eucjp2sjis_infos,
+
+#define sjis2eucjp_81to9F WORDINDEX2INFO(24)
+ sjis2eucjp_81to9F_offsets,
+ eucjp2sjis_A1toFE_infos,
+
+#define sjis2eucjp_F0toFC WORDINDEX2INFO(26)
+ sjis2eucjp_81to9F_offsets,
+ eucjp2sjis_8F_A1toFE_infos,
+
+#define sjis2eucjp_infos WORDINDEX2INFO(28)
+ NOMAP, INVALID,
+ sjis2eucjp_81to9F, FUNso,
+ sjis2eucjp_F0toFC,
+
+#define sjis2eucjp WORDINDEX2INFO(33)
+ sjis2eucjp_offsets,
+ sjis2eucjp_infos,
+
+};
+#define TRANSCODE_TABLE_INFO japanese_byte_array, 895, japanese_word_array, 35, ((int)sizeof(unsigned int))
+
+
+static ssize_t
+fun_so_eucjp2sjis(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
+{
+ if (s[0] == 0x8e) {
+ o[0] = s[1];
+ return 1;
+ }
+ else {
+ int h, m, l;
+ m = s[0] & 1;
+ h = (s[0]+m) >> 1;
+ h += s[0] < 0xdf ? 0x30 : 0x70;
+ l = s[1] - m * 94 - 3;
+ if (0x7f <= l)
+ l++;
+ o[0] = h;
+ o[1] = l;
+ return 2;
+ }
+}
+
+static ssize_t
+fun_so_sjis2eucjp(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
+{
+ if (l == 1) {
+ o[0] = '\x8e';
+ o[1] = s[0];
+ return 2;
+ }
+ else {
+ int h, l;
+ h = s[0];
+ l = s[1];
+ if (0xe0 <= h)
+ h -= 64;
+ l += l < 0x80 ? 0x61 : 0x60;
+ h = h * 2 - 0x61;
+ if (0xfe < l) {
+ l -= 94;
+ h += 1;
+ }
+ o[0] = h;
+ o[1] = l;
+ return 2;
+ }
+}
+
+static const rb_transcoder
+rb_eucjp2sjis = {
+ "EUC-JP", "Shift_JIS", eucjp2sjis,
+ TRANSCODE_TABLE_INFO,
+ 1, /* input_unit_length */
+ 3, /* max_input */
+ 2, /* max_output */
+ asciicompat_converter, /* asciicompat_type */
+ 0, NULL, NULL, /* state_size, state_init, state_fini */
+ NULL, NULL, NULL, fun_so_eucjp2sjis
+};
+
+static const rb_transcoder
+rb_sjis2eucjp = {
+ "Shift_JIS", "EUC-JP", sjis2eucjp,
+ TRANSCODE_TABLE_INFO,
+ 1, /* input_unit_length */
+ 2, /* max_input */
+ 2, /* max_output */
+ asciicompat_converter, /* asciicompat_type */
+ 0, NULL, NULL, /* state_size, state_init, state_fini */
+ NULL, NULL, NULL, fun_so_sjis2eucjp
+};
+
+TRANS_INIT(japanese)
+{
+ rb_register_transcoder(&rb_eucjp2sjis);
+ rb_register_transcoder(&rb_sjis2eucjp);
+}
+