[KoCo-CVS] [Commit] cjkcodecs/src _cp932.c
Brought to you by:
perky
From: Hye-Shik C. <pe...@us...> - 2003-06-20 09:04:54
|
perky 03/06/20 02:04:53 Modified: src _cp932.c Log: - Tweaked some mapping for cp932 and cp950 to make more consistency with MS Windows. - CP932: Added single byte "UNDEFINED" characters 0x80, 0xa0, 0xfd, 0xfe, 0xff (documented on NOTES.cp932) - CP950: Changed encode mappings to another more popular for duplicated unicode points: 5341 -> A451, 5345 -> A4CA - A unittest for big5 mapping is added. - Fixed a bug that cp932 codec couldn't decode half-width katakana. Revision Changes Path 1.4 +24 -3 cjkcodecs/src/_cp932.c Index: _cp932.c =================================================================== RCS file: /cvsroot/koco/cjkcodecs/src/_cp932.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- _cp932.c 9 Jun 2003 10:25:36 -0000 1.3 +++ _cp932.c 20 Jun 2003 09:04:52 -0000 1.4 @@ -26,7 +26,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: _cp932.c,v 1.3 2003/06/09 10:25:36 perky Exp $ + * $Id: _cp932.c,v 1.4 2003/06/20 09:04:52 perky Exp $ */ #include "codeccommon.h" @@ -43,7 +43,7 @@ DBCHAR code; unsigned char c1, c2; - if (c < 0x80) { + if (c <= 0x80) { RESERVE_OUTBUF(1) **outbuf = (unsigned char)c; NEXT(1, 1) @@ -53,6 +53,15 @@ **outbuf = (unsigned char)(c - 0xfec0); NEXT(1, 1) continue; + } else if (c >= 0xf8f0 && c <= 0xf8f3) { + /* Windows compatability */ + RESERVE_OUTBUF(1) + if (c == 0xf8f0) + **outbuf = 0xa0; + else + **outbuf = (unsigned char)(c - 0xfef1 + 0xfd); + NEXT(1, 1) + continue; } UCS4INVALID(c) @@ -93,8 +102,20 @@ unsigned char c = **inbuf, c2; RESERVE_OUTBUF(1) - if (c < 0x80) { + if (c <= 0x80) { **outbuf = c; + NEXT(1, 1) + continue; + } else if (c >= 0xa0 && c <= 0xdf) { + if (c == 0xa0) + **outbuf = 0xf8f0; /* half-width katakana */ + else + **outbuf = 0xfec0 + c; + NEXT(1, 1) + continue; + } else if (c >= 0xfd/* && c <= 0xff*/) { + /* Windows compatibility */ + **outbuf = 0xf8f1 - 0xfd + c; NEXT(1, 1) continue; } |