00001
00002
00003
00004
00005
00006
00007 static const unsigned short cp1133_2uni_1[64] = {
00008
00009 0x00a0, 0x0e81, 0x0e82, 0x0e84, 0x0e87, 0x0e88, 0x0eaa, 0x0e8a,
00010 0x0e8d, 0x0e94, 0x0e95, 0x0e96, 0x0e97, 0x0e99, 0x0e9a, 0x0e9b,
00011
00012 0x0e9c, 0x0e9d, 0x0e9e, 0x0e9f, 0x0ea1, 0x0ea2, 0x0ea3, 0x0ea5,
00013 0x0ea7, 0x0eab, 0x0ead, 0x0eae, 0xfffd, 0xfffd, 0xfffd, 0x0eaf,
00014
00015 0x0eb0, 0x0eb2, 0x0eb3, 0x0eb4, 0x0eb5, 0x0eb6, 0x0eb7, 0x0eb8,
00016 0x0eb9, 0x0ebc, 0x0eb1, 0x0ebb, 0x0ebd, 0xfffd, 0xfffd, 0xfffd,
00017
00018 0x0ec0, 0x0ec1, 0x0ec2, 0x0ec3, 0x0ec4, 0x0ec8, 0x0ec9, 0x0eca,
00019 0x0ecb, 0x0ecc, 0x0ecd, 0x0ec6, 0xfffd, 0x0edc, 0x0edd, 0x20ad,
00020 };
00021 static const unsigned short cp1133_2uni_2[16] = {
00022
00023 0x0ed0, 0x0ed1, 0x0ed2, 0x0ed3, 0x0ed4, 0x0ed5, 0x0ed6, 0x0ed7,
00024 0x0ed8, 0x0ed9, 0xfffd, 0xfffd, 0x00a2, 0x00ac, 0x00a6, 0xfffd,
00025 };
00026
00027 static int
00028 cp1133_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
00029 {
00030 unsigned char c = *s;
00031 if (c < 0xa0) {
00032 *pwc = (ucs4_t) c;
00033 return 1;
00034 }
00035 else if (c < 0xe0) {
00036 unsigned short wc = cp1133_2uni_1[c-0xa0];
00037 if (wc != 0xfffd) {
00038 *pwc = (ucs4_t) wc;
00039 return 1;
00040 }
00041 }
00042 else if (c < 0xf0) {
00043 }
00044 else {
00045 unsigned short wc = cp1133_2uni_2[c-0xf0];
00046 if (wc != 0xfffd) {
00047 *pwc = (ucs4_t) wc;
00048 return 1;
00049 }
00050 }
00051 return RET_ILSEQ;
00052 }
00053
00054 static const unsigned char cp1133_page00[16] = {
00055 0xa0, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfe, 0x00,
00056 0x00, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x00,
00057 };
00058 static const unsigned char cp1133_page0e[96] = {
00059 0x00, 0xa1, 0xa2, 0x00, 0xa3, 0x00, 0x00, 0xa4,
00060 0xa5, 0x00, 0xa7, 0x00, 0x00, 0xa8, 0x00, 0x00,
00061 0x00, 0x00, 0x00, 0x00, 0xa9, 0xaa, 0xab, 0xac,
00062 0x00, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3,
00063 0x00, 0xb4, 0xb5, 0xb6, 0x00, 0xb7, 0x00, 0xb8,
00064 0x00, 0x00, 0xa6, 0xb9, 0x00, 0xba, 0xbb, 0xbf,
00065 0xc0, 0xca, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6,
00066 0xc7, 0xc8, 0x00, 0xcb, 0xc9, 0xcc, 0x00, 0x00,
00067 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0x00, 0xdb, 0x00,
00068 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0x00, 0x00,
00069 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
00070 0xf8, 0xf9, 0x00, 0x00, 0xdd, 0xde, 0x00, 0x00,
00071 };
00072
00073 static int
00074 cp1133_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
00075 {
00076 unsigned char c = 0;
00077 if (wc < 0x00a0) {
00078 *r = wc;
00079 return 1;
00080 }
00081 else if (wc >= 0x00a0 && wc < 0x00b0)
00082 c = cp1133_page00[wc-0x00a0];
00083 else if (wc >= 0x0e80 && wc < 0x0ee0)
00084 c = cp1133_page0e[wc-0x0e80];
00085 else if (wc == 0x20ad)
00086 c = 0xdf;
00087 if (c != 0) {
00088 *r = c;
00089 return 1;
00090 }
00091 return RET_ILSEQ;
00092 }