Fix bugs in EUC_TW support. This fix includes patches contributed
authorTatsuo Ishii <[email protected]>
Fri, 17 Nov 2000 04:53:54 +0000 (04:53 +0000)
committerTatsuo Ishii <[email protected]>
Fri, 17 Nov 2000 04:53:54 +0000 (04:53 +0000)
by Chih-Chang Hsi. See "A Patch for MIC to EUC_TW code converting in
mb support" posting in pgsql-patches list dated 09 Nov 2000.

src/backend/utils/mb/conv.c

index 7ee42f0e336f155fd008192da80c3545487f87e7..869e9b2409ba53dbb9a502c95e7a2aad31709e30 100644 (file)
@@ -6,7 +6,7 @@
  * WIN1250 client encoding support contributed by Pavel Behal
  * SJIS UDC (NEC selection IBM kanji) support contributed by Eiji Tokuya
  *
- * $Id: conv.c,v 1.15 2000/05/20 13:12:26 ishii Exp $
+ * $Id: conv.c,v 1.15.2.1 2000/11/17 04:53:54 ishii Exp $
  *
  *
  */
@@ -906,15 +906,22 @@ mic2euc_tw(unsigned char *mic, unsigned char *p, int len)
    {
        len -= pg_mic_mblen(mic++);
 
-       if (c1 == LC_CNS11643_1 || c1 == LC_CNS11643_2)
+       if (c1 == LC_CNS11643_1)
        {
            *p++ = *mic++;
            *p++ = *mic++;
        }
+       else if (c1 == LC_CNS11643_2)
+       {
+           *p++ = SS2;
+           *p++ = 0xa2;
+           *p++ = *mic++;
+           *p++ = *mic++;
+       }
        else if (c1 == 0x9d)
        {                       /* LCPRV2? */
            *p++ = SS2;
-           *p++ = c1 - LC_CNS11643_3 + 0xa3;
+           *p++ = *mic++ - LC_CNS11643_3 + 0xa3;
            *p++ = *mic++;
            *p++ = *mic++;
        }
@@ -941,7 +948,7 @@ big52mic(unsigned char *big5, unsigned char *p, int len)
    unsigned short big5buf,
                cnsBuf;
    unsigned char lc;
-   char        bogusBuf[2];
+   char        bogusBuf[3];
    int         i;
 
    while (len > 0 && (c1 = *big5++))