11/*
2- * Copyright (C) 1999-2001, 2005 Free Software Foundation, Inc.
2+ * Copyright (C) 1999-2001, 2005, 2011 Free Software Foundation, Inc.
33 * This file is part of the GNU LIBICONV Library.
44 *
55 * The GNU LIBICONV Library is free software; you can redistribute it
@@ -27,20 +27,20 @@ static const unsigned short gb18030ext_2uni_pagea9[13] = {
2727 0x303e , 0x2ff0 , 0x2ff1 , 0x2ff2 , 0x2ff3 , 0x2ff4 , 0x2ff5 , 0x2ff6 ,
2828 0x2ff7 , 0x2ff8 , 0x2ff9 , 0x2ffa , 0x2ffb ,
2929};
30- static const unsigned short gb18030ext_2uni_pagefe [96 ] = {
30+ static const unsigned int gb18030ext_2uni_pagefe [96 ] = {
3131 /* 0xfe */
32- 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd ,
33- 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd ,
34- 0x2e81 , 0xe816 , 0xe817 , 0xe818 , 0x2e84 , 0x3473 , 0x3447 , 0x2e88 ,
35- 0x2e8b , 0xe81e , 0x359e , 0x361a , 0x360e , 0x2e8c , 0x2e97 , 0x396e ,
36- 0x3918 , 0xe826 , 0x39cf , 0x39df , 0x3a73 , 0x39d0 , 0xe82b , 0xe82c ,
37- 0x3b4e , 0x3c6e , 0x3ce0 , 0x2ea7 , 0xe831 , 0xe832 , 0x2eaa , 0x4056 ,
38- 0x415f , 0x2eae , 0x4337 , 0x2eb3 , 0x2eb6 , 0x2eb7 , 0xe83b , 0x43b1 ,
39- 0x43ac , 0x2ebb , 0x43dd , 0x44d6 , 0x4661 , 0x464c , 0xe843 , 0x4723 ,
40- 0x4729 , 0x477c , 0x478d , 0x2eca , 0x4947 , 0x497a , 0x497d , 0x4982 ,
41- 0x4983 , 0x4985 , 0x4986 , 0x499f , 0x499b , 0x49b7 , 0x49b6 , 0xe854 ,
42- 0xe855 , 0x4ca3 , 0x4c9f , 0x4ca0 , 0x4ca1 , 0x4c77 , 0x4ca2 , 0x4d13 ,
43- 0x4d14 , 0x4d15 , 0x4d16 , 0x4d17 , 0x4d18 , 0x4d19 , 0x4dae , 0xe864 ,
32+ 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd ,
33+ 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd , 0xfffd ,
34+ 0x2e81 , 0x20087 , 0x20089 , 0x200cc , 0x2e84 , 0x3473 , 0x3447 , 0x2e88 ,
35+ 0x2e8b , 0x9fb4 , 0x359e , 0x361a , 0x360e , 0x2e8c , 0x2e97 , 0x396e ,
36+ 0x3918 , 0x9fb5 , 0x39cf , 0x39df , 0x3a73 , 0x39d0 , 0x9fb6 , 0x9fb7 ,
37+ 0x3b4e , 0x3c6e , 0x3ce0 , 0x2ea7 , 0x215d7 , 0x9fb8 , 0x2eaa , 0x4056 ,
38+ 0x415f , 0x2eae , 0x4337 , 0x2eb3 , 0x2eb6 , 0x2eb7 , 0x2298f , 0x43b1 ,
39+ 0x43ac , 0x2ebb , 0x43dd , 0x44d6 , 0x4661 , 0x464c , 0x9fb9 , 0x4723 ,
40+ 0x4729 , 0x477c , 0x478d , 0x2eca , 0x4947 , 0x497a , 0x497d , 0x4982 ,
41+ 0x4983 , 0x4985 , 0x4986 , 0x499f , 0x499b , 0x49b7 , 0x49b6 , 0x9fba ,
42+ 0x241fe , 0x4ca3 , 0x4c9f , 0x4ca0 , 0x4ca1 , 0x4c77 , 0x4ca2 , 0x4d13 ,
43+ 0x4d14 , 0x4d15 , 0x4d16 , 0x4d17 , 0x4d18 , 0x4d19 , 0x4dae , 0x9fbb ,
4444};
4545
4646static int
@@ -52,7 +52,7 @@ gb18030ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
5252 unsigned char c2 = s [1 ];
5353 if ((c2 >= 0x40 && c2 < 0x7f ) || (c2 >= 0x80 && c2 < 0xff )) {
5454 unsigned int i = 190 * (c1 - 0x81 ) + (c2 - (c2 >= 0x80 ? 0x41 : 0x40 ));
55- unsigned short wc = 0xfffd ;
55+ unsigned int wc = 0xfffd ;
5656 switch (c1 ) {
5757 case 0xa2 :
5858 if (i >= 6376 && i <= 6381 ) /* 0xA2AB..0xA2B0 */
@@ -77,12 +77,14 @@ gb18030ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
7777 case 0xa6 :
7878 if (i >= 7150 && i <= 7157 ) /* 0xA6B9..0xA6C0 */
7979 wc = 0xe785 + (i - 7150 );
80+ else if (i >= 7183 && i <= 7184 ) /* 0xA6DA..0xA6DB */
81+ wc = 0xfe12 - (i - 7183 );
8082 else if (i >= 7182 && i <= 7190 ) /* 0xA6D9..0xA6DF */
81- wc = 0xe78d + (i - 7182 );
83+ wc = 0xfe10 + (i - 7182 );
8284 else if (i >= 7201 && i <= 7202 ) /* 0xA6EC..0xA6ED */
83- wc = 0xe794 + (i - 7201 );
85+ wc = 0xfe17 + (i - 7201 );
8486 else if (i == 7208 ) /* 0xA6F3 */
85- wc = 0xe796 ;
87+ wc = 0xfe19 ;
8688 else if (i >= 7211 && i <= 7219 ) /* 0xA6F6..0xA6FE */
8789 wc = 0xe797 + (i - 7211 );
8890 break ;
@@ -96,7 +98,7 @@ gb18030ext_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)
9698 if (i >= 7495 && i <= 7505 ) /* 0xA896..0xA8A0 */
9799 wc = 0xe7bc + (i - 7495 );
98100 else if (i == 7533 ) /* 0xA8BC */
99- wc = 0xe7c7 ;
101+ wc = 0x1e3f ;
100102 else if (i == 7536 ) /* 0xA8BF */
101103 wc = 0x01f9 ;
102104 else if (i >= 7538 && i <= 7541 ) /* 0xA8C1..0xA8C4 */
@@ -230,6 +232,14 @@ static const unsigned short gb18030ext_page4d[16] = {
230232 0x0000 , 0x0000 , 0x0000 , 0xfe98 , 0xfe99 , 0xfe9a , 0xfe9b , 0xfe9c , /*0x10-0x17*/
231233 0xfe9d , 0xfe9e , 0x0000 , 0x0000 , 0x0000 , 0x0000 , 0x0000 , 0x0000 , /*0x18-0x1f*/
232234};
235+ static const unsigned short gb18030ext_page9f [16 ] = {
236+ 0x0000 , 0x0000 , 0x0000 , 0x0000 , 0xfe59 , 0xfe61 , 0xfe66 , 0xfe67 , /*0xb0-0xb7*/
237+ 0xfe6d , 0xfe7e , 0xfe90 , 0xfea0 , 0x0000 , 0x0000 , 0x0000 , 0x0000 , /*0xb8-0xbf*/
238+ };
239+ static const unsigned short gb18030ext_pagefe [16 ] = {
240+ 0xa6d9 , 0xa6db , 0xa6da , 0xa6dc , 0xa6dd , 0xa6de , 0xa6df , 0xa6ec , /*0x10-0x17*/
241+ 0xa6ed , 0xa6f3 , 0x0000 , 0x0000 , 0x0000 , 0x0000 , 0x0000 , 0x0000 , /*0x18-0x1f*/
242+ };
233243
234244static int
235245gb18030ext_wctomb (conv_t conv , unsigned char * r , ucs4_t wc , int n )
@@ -238,6 +248,8 @@ gb18030ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
238248 unsigned short c = 0 ;
239249 if (wc == 0x01f9 )
240250 c = 0xa8bf ;
251+ else if (wc == 0x1e3f )
252+ c = 0xa8bc ;
241253 else if (wc == 0x20ac )
242254 c = 0xa2e3 ;
243255 else if (wc >= 0x2e80 && wc < 0x2ed0 )
@@ -290,6 +302,22 @@ gb18030ext_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
290302 c = gb18030ext_page4d [wc - 0x4d10 ];
291303 else if (wc == 0x4dae )
292304 c = 0xfe9f ;
305+ else if (wc >= 0x9fb4 && wc < 0x9fbc )
306+ c = gb18030ext_page9f [wc - 0x9fb0 ];
307+ else if (wc >= 0xfe10 && wc < 0xfe1a )
308+ c = gb18030ext_pagefe [wc - 0xfe10 ];
309+ else if (wc == 0x20087 )
310+ c = 0xfe51 ;
311+ else if (wc == 0x20089 )
312+ c = 0xfe52 ;
313+ else if (wc == 0x200cc )
314+ c = 0xfe53 ;
315+ else if (wc == 0x215d7 )
316+ c = 0xfe6c ;
317+ else if (wc == 0x2298f )
318+ c = 0xfe76 ;
319+ else if (wc == 0x241fe )
320+ c = 0xfe91 ;
293321 if (c != 0 ) {
294322 r [0 ] = (c >> 8 ); r [1 ] = (c & 0xff );
295323 return 2 ;
0 commit comments