aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c17
-rw-r--r--src/backend/utils/mb/wchar.c6
2 files changed, 14 insertions, 9 deletions
diff --git a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
index a266824b6bc..ed0e0c185cc 100644
--- a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
+++ b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c
@@ -168,7 +168,8 @@ euc_tw2mic(const unsigned char *euc, unsigned char *p, int len)
*p++ = LC_CNS11643_2;
else
{
- *p++ = 0x9d; /* LCPRV2 */
+ /* other planes are MULE private charsets */
+ *p++ = LCPRV2_B;
*p++ = c1 - 0xa3 + LC_CNS11643_3;
}
*p++ = euc[2];
@@ -235,9 +236,9 @@ mic2euc_tw(const unsigned char *mic, unsigned char *p, int len)
*p++ = mic[1];
*p++ = mic[2];
}
- else if (c1 == 0x9d &&
+ else if (c1 == LCPRV2_B &&
mic[1] >= LC_CNS11643_3 && mic[1] <= LC_CNS11643_7)
- { /* LCPRV2? */
+ {
*p++ = SS2;
*p++ = mic[1] - LC_CNS11643_3 + 0xa3;
*p++ = mic[2];
@@ -286,10 +287,9 @@ big52mic(const unsigned char *big5, unsigned char *p, int len)
cnsBuf = BIG5toCNS(big5buf, &lc);
if (lc != 0)
{
+ /* Planes 3 and 4 are MULE private charsets */
if (lc == LC_CNS11643_3 || lc == LC_CNS11643_4)
- {
- *p++ = 0x9d; /* LCPRV2 */
- }
+ *p++ = LCPRV2_B;
*p++ = lc; /* Plane No. */
*p++ = (cnsBuf >> 8) & 0x00ff;
*p++ = cnsBuf & 0x00ff;
@@ -332,10 +332,9 @@ mic2big5(const unsigned char *mic, unsigned char *p, int len)
if (l < 0)
report_invalid_encoding(PG_MULE_INTERNAL,
(const char *) mic, len);
- /* 0x9d means LCPRV2 */
- if (c1 == LC_CNS11643_1 || c1 == LC_CNS11643_2 || c1 == 0x9d)
+ if (c1 == LC_CNS11643_1 || c1 == LC_CNS11643_2 || c1 == LCPRV2_B)
{
- if (c1 == 0x9d)
+ if (c1 == LCPRV2_B)
{
c1 = mic[1]; /* get plane no. */
cnsBuf = (mic[2] << 8) | mic[3];
diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c
index 03d68119d1c..2e1db5ebf4b 100644
--- a/src/backend/utils/mb/wchar.c
+++ b/src/backend/utils/mb/wchar.c
@@ -742,6 +742,12 @@ pg_mule_dsplen(const unsigned char *s)
{
int len;
+ /*
+ * Note: it's not really appropriate to assume that all multibyte charsets
+ * are double-wide on screen. But this seems an okay approximation for
+ * the MULE charsets we currently support.
+ */
+
if (IS_LC1(*s))
len = 1;
else if (IS_LCPRV1(*s))