23
23
#define PType (unsigned int)
25
#define NOMAP (PType 0x01) /* single byte direct map */
25
#define NOMAP (PType 0x01) /* direct map */
26
26
#define ONEbt (0x02) /* one byte payload */
27
27
#define TWObt (0x03) /* two bytes payload */
28
28
#define THREEbt (0x05) /* three bytes payload */
36
36
#define FUNso (PType 0x0F) /* function from start to output */
37
37
#define STR1 (PType 0x11) /* string 4 <= len <= 259 bytes: 1byte length + content */
38
38
#define GB4bt (PType 0x12) /* GB18030 four bytes payload */
39
#define FUNsio (PType 0x13) /* function from start and info to output */
40
#define STR1_LENGTH(byte_addr) (*(byte_addr) + 4)
41
#define STR1_LENGTH(byte_addr) (unsigned int)(*(byte_addr) + 4)
41
42
#define STR1_BYTEINDEX(w) ((w) >> 6)
42
43
#define makeSTR1(bi) (((bi) << 6) | STR1)
43
44
#define makeSTR1LEN(len) ((len)-4)
45
46
#define o1(b1) (PType((((unsigned char)(b1))<<8)|ONEbt))
46
47
#define o2(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|TWObt))
47
#define o3(b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|(((unsigned char)(b3))<<24)|THREEbt)&0xffffffffU))
48
#define o3(b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|(((unsigned int)(unsigned char)(b3))<<24)|THREEbt)&0xffffffffU))
48
49
#define o4(b0,b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|(((unsigned char)(b3))<<24)|((((unsigned char)(b0))&0x07)<<5)|FOURbt)&0xffffffffU))
49
#define g4(b0,b1,b2,b3) (PType(((((unsigned char)(b0))<<8)|(((unsigned char)(b2))<<16)|((((unsigned char)(b1))&0x0f)<<24)|((((unsigned char)(b3))&0x0f)<<28)|GB4bt)&0xffffffffU))
51
#define getBT1(a) (((a)>> 8)&0xFF)
52
#define getBT2(a) (((a)>>16)&0xFF)
53
#define getBT3(a) (((a)>>24)&0xFF)
54
#define getBT0(a) ((((a)>> 5)&0x07)|0xF0) /* for UTF-8 only!!! */
56
#define getGB4bt0(a) (((a)>> 8)&0xFF)
57
#define getGB4bt1(a) (((a)>>24)&0x0F|0x30)
58
#define getGB4bt2(a) (((a)>>16)&0xFF)
59
#define getGB4bt3(a) (((a)>>28)&0x0F|0x30)
50
#define g4(b0,b1,b2,b3) (PType(((((unsigned char)(b0))<<8)|(((unsigned char)(b2))<<16)|((((unsigned char)(b1))&0x0f)<<24)|((((unsigned int)(unsigned char)(b3))&0x0f)<<28)|GB4bt)&0xffffffffU))
51
#define funsio(diff) (PType((((unsigned int)(diff))<<8)|FUNsio))
53
#define getBT1(a) ((unsigned char)((a)>> 8))
54
#define getBT2(a) ((unsigned char)((a)>>16))
55
#define getBT3(a) ((unsigned char)((a)>>24))
56
#define getBT0(a) (((unsigned char)((a)>> 5)&0x07)|0xF0) /* for UTF-8 only!!! */
58
#define getGB4bt0(a) ((unsigned char)((a)>> 8))
59
#define getGB4bt1(a) ((unsigned char)((a)>>24)&0x0F|0x30)
60
#define getGB4bt2(a) ((unsigned char)((a)>>16))
61
#define getGB4bt3(a) ((unsigned char)((a)>>28)&0x0F|0x30)
61
63
#define o2FUNii(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|FUNii))
69
71
asciicompat_converter, /* ASCII-compatible -> ASCII-compatible */
70
72
asciicompat_decoder, /* ASCII-incompatible -> ASCII-compatible */
71
73
asciicompat_encoder /* ASCII-compatible -> ASCII-incompatible */
72
/* ASCII-incompatible -> ASCII-incompatible is intentionally ommitted. */
74
/* ASCII-incompatible -> ASCII-incompatible is intentionally omitted. */
73
75
} rb_transcoder_asciicompat_type_t;
75
77
typedef struct rb_transcoder rb_transcoder;
98
100
ssize_t (*finish_func)(void*, unsigned char*, size_t); /* -> output */
99
101
ssize_t (*resetsize_func)(void*); /* -> len */
100
102
ssize_t (*resetstate_func)(void*, unsigned char*, size_t); /* -> output */
103
ssize_t (*func_sio)(void*, const unsigned char*, size_t, VALUE, unsigned char*, size_t); /* start -> output */
103
106
void rb_declare_transcoder(const char *enc1, const char *enc2, const char *lib);