1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

Improve documentation about MULE encoding.

This commit improves the comments in pg_wchar.h and creates #define symbols
for some formerly hard-coded values.  No substantive code changes.

Tatsuo Ishii and Tom Lane
This commit is contained in:
Tom Lane
2012-07-04 00:29:57 -04:00
parent 47a2adc83c
commit 09022de1f5
3 changed files with 111 additions and 59 deletions

View File

@@ -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];

View File

@@ -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))