/* autogenerated. */
/* src="transcode-tblgen.rb", len=30702, checksum=50180 */
/* src="cesu_8.trans", len=2584, checksum=62095 */

#include "transcode_data.h"



static const unsigned char
cesu_8_byte_array[762] = {
#define from_CESU_8_C2toDF_offsets 0
128, 191,
      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,  1,

#define from_CESU_8_E0_offsets 66
160, 191,
      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,

#define from_CESU_8_ED_A0toAF_80toBF_ED_offsets 100
176, 191,
      1,  1,  1,  1,  1,  1,  1,  1,    1,  1,  1,  1,  1,  1,  1,  1,

#define from_CESU_8_ED_A0toAF_80toBF_offsets 118
237, 237,
      1,

#define from_CESU_8_ED_offsets 121
128, 175,
      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,

#define from_CESU_8_offsets 171
0, 239,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      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,  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,
      3,  4,  4,  4,  4,  4,  4,  4,    4,  4,  4,  4,  4,  5,  4,  4,

#define to_CESU_8_ED_offsets 413
128, 159,
      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,

#define to_CESU_8_F0_offsets 447
144, 191,
      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,

#define to_CESU_8_F4_offsets 497
128, 143,
      1,  1,  1,  1,  1,  1,  1,  1,    1,  1,  1,  1,  1,  1,  1,  1,

#define to_CESU_8_offsets 515
0, 244,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,
      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,  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,
      3,  4,  4,  4,  4,  4,  4,  4,    4,  4,  4,  4,  4,  5,  4,  4,
      6,  7,  7,  7,  8,

};
static const unsigned int
cesu_8_word_array[62] = {
#define from_CESU_8_C2toDF_infos WORDINDEX2INFO(0)
     INVALID,   NOMAP,

#define from_CESU_8_C2toDF WORDINDEX2INFO(2)
    from_CESU_8_C2toDF_offsets,
    from_CESU_8_C2toDF_infos,

#define from_CESU_8_E0_infos WORDINDEX2INFO(4)
                INVALID, from_CESU_8_C2toDF,

#define from_CESU_8_E0 WORDINDEX2INFO(6)
    from_CESU_8_E0_offsets,
    from_CESU_8_E0_infos,

#define from_CESU_8_E1toEC WORDINDEX2INFO(8)
    from_CESU_8_C2toDF_offsets,
    from_CESU_8_E0_infos,

#define from_CESU_8_ED_A0toAF_80toBF_ED_B0toBF_infos WORDINDEX2INFO(10)
     INVALID,   FUNso,

#define from_CESU_8_ED_A0toAF_80toBF_ED_B0toBF WORDINDEX2INFO(12)
    from_CESU_8_C2toDF_offsets,
    from_CESU_8_ED_A0toAF_80toBF_ED_B0toBF_infos,

#define from_CESU_8_ED_A0toAF_80toBF_ED_infos WORDINDEX2INFO(14)
                                    INVALID, from_CESU_8_ED_A0toAF_80toBF_ED_B0toBF,

#define from_CESU_8_ED_A0toAF_80toBF_ED WORDINDEX2INFO(16)
    from_CESU_8_ED_A0toAF_80toBF_ED_offsets,
    from_CESU_8_ED_A0toAF_80toBF_ED_infos,

#define from_CESU_8_ED_A0toAF_80toBF_infos WORDINDEX2INFO(18)
                             INVALID, from_CESU_8_ED_A0toAF_80toBF_ED,

#define from_CESU_8_ED_A0toAF_80toBF WORDINDEX2INFO(20)
    from_CESU_8_ED_A0toAF_80toBF_offsets,
    from_CESU_8_ED_A0toAF_80toBF_infos,

#define from_CESU_8_ED_A0toAF_infos WORDINDEX2INFO(22)
                          INVALID, from_CESU_8_ED_A0toAF_80toBF,

#define from_CESU_8_ED_A0toAF WORDINDEX2INFO(24)
    from_CESU_8_C2toDF_offsets,
    from_CESU_8_ED_A0toAF_infos,

#define from_CESU_8_ED_infos WORDINDEX2INFO(26)
                   INVALID,    from_CESU_8_C2toDF,
     from_CESU_8_ED_A0toAF,

#define from_CESU_8_ED WORDINDEX2INFO(29)
    from_CESU_8_ED_offsets,
    from_CESU_8_ED_infos,

#define from_CESU_8_infos WORDINDEX2INFO(31)
                  NOMAP,            INVALID,
     from_CESU_8_C2toDF,     from_CESU_8_E0,
     from_CESU_8_E1toEC,     from_CESU_8_ED,

#define from_CESU_8 WORDINDEX2INFO(37)
    from_CESU_8_offsets,
    from_CESU_8_infos,

#define to_CESU_8_ED WORDINDEX2INFO(39)
    to_CESU_8_ED_offsets,
    from_CESU_8_E0_infos,

#define to_CESU_8_F0_90toBF WORDINDEX2INFO(41)
    from_CESU_8_C2toDF_offsets,
    from_CESU_8_ED_A0toAF_80toBF_ED_infos,

#define to_CESU_8_F0_infos WORDINDEX2INFO(43)
                 INVALID, to_CESU_8_F0_90toBF,

#define to_CESU_8_F0 WORDINDEX2INFO(45)
    to_CESU_8_F0_offsets,
    to_CESU_8_F0_infos,

#define to_CESU_8_F1toF3 WORDINDEX2INFO(47)
    from_CESU_8_C2toDF_offsets,
    to_CESU_8_F0_infos,

#define to_CESU_8_F4 WORDINDEX2INFO(49)
    to_CESU_8_F4_offsets,
    to_CESU_8_F0_infos,

#define to_CESU_8_infos WORDINDEX2INFO(51)
                  NOMAP,            INVALID,
     from_CESU_8_C2toDF,     from_CESU_8_E0,
     from_CESU_8_E1toEC,       to_CESU_8_ED,
           to_CESU_8_F0,   to_CESU_8_F1toF3,
           to_CESU_8_F4,

#define to_CESU_8 WORDINDEX2INFO(60)
    to_CESU_8_offsets,
    to_CESU_8_infos,

};
#define TRANSCODE_TABLE_INFO cesu_8_byte_array, 762, cesu_8_word_array, 62, ((int)sizeof(unsigned int))


static ssize_t
fun_so_from_cesu_8(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
{
    unsigned int scalar = ( ((s[1]&0x0F)<<16) | ((s[2]&0x3F)<<10)
                          | ((s[4]&0x0F)<< 6) |  (s[5]&0x3F)
                          ) + 0x10000;
    o[0] = 0xF0 |  (scalar>>18);
    o[1] = 0x80 | ((scalar>>12)&0x3F);
    o[2] = 0x80 | ((scalar>> 6)&0x3F);
    o[3] = 0x80 | ( scalar     &0x3F);
    return 4;
}

static ssize_t
fun_so_to_cesu_8(void *statep, const unsigned char *s, size_t l, unsigned char *o, size_t osize)
{
    unsigned int scalar = ((s[0]&0x07)<<18) | ((s[1]&0x3F)<<12)
                        | ((s[2]&0x3F)<< 6) |  (s[3]&0x3F);
    scalar -= 0x10000;
    o[0] = 0xED;
    o[1] = 0xA0 |  (scalar>>16);
    o[2] = 0x80 | ((scalar>>10)&0x3F);
    o[3] = 0xED;
    o[4] = 0xB0 | ((scalar>> 6)&0x0F);
    o[5] = 0x80 | (scalar      &0x3F);
    return 6;
}

static const rb_transcoder
rb_from_CESU_8 = {
    "CESU-8", "UTF-8", from_CESU_8,
    TRANSCODE_TABLE_INFO,
    1, /* input_unit_length */
    6, /* max_input */
    4, /* max_output */
    asciicompat_decoder, /* asciicompat_type */
    0, NULL, NULL, /* state_size, state_init, state_fini */
    NULL, NULL, NULL, fun_so_from_cesu_8
};

static const rb_transcoder
rb_to_CESU_8 = {
    "UTF-8", "CESU-8", to_CESU_8,
    TRANSCODE_TABLE_INFO,
    1, /* input_unit_length */
    4, /* max_input */
    6, /* max_output */
    asciicompat_encoder, /* asciicompat_type */
    0, NULL, NULL, /* state_size, state_init, state_fini */
    NULL, NULL, NULL, fun_so_to_cesu_8
};

TRANS_INIT(cesu_8)
{
    rb_register_transcoder(&rb_from_CESU_8);
    rb_register_transcoder(&rb_to_CESU_8);
}

