mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
pgindent run.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conv.c,v 1.42 2002/08/14 02:45:10 ishii Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conv.c,v 1.43 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -52,11 +52,12 @@ gb180302mic(unsigned char *gb18030, unsigned char *p, int len)
|
||||
len--;
|
||||
*p++ = c1;
|
||||
}
|
||||
else if(c1 >= 0x81 && c1 <= 0xfe)
|
||||
else if (c1 >= 0x81 && c1 <= 0xfe)
|
||||
{
|
||||
c2 = *gb18030++;
|
||||
|
||||
if(c2 >= 0x30 && c2 <= 0x69){
|
||||
|
||||
if (c2 >= 0x30 && c2 <= 0x69)
|
||||
{
|
||||
len -= 4;
|
||||
*p++ = c1;
|
||||
*p++ = c2;
|
||||
@@ -64,13 +65,15 @@ gb180302mic(unsigned char *gb18030, unsigned char *p, int len)
|
||||
*p++ = *gb18030++;
|
||||
*p++ = *gb18030++;
|
||||
}
|
||||
else if ((c2 >=0x40 && c2 <= 0x7e) ||(c2 >=0x80 && c2 <= 0xfe)){
|
||||
else if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfe))
|
||||
{
|
||||
len -= 2;
|
||||
*p++ = c1;
|
||||
*p++ = c2;
|
||||
*p++ = *gb18030++;
|
||||
}
|
||||
else{ /*throw the strange code*/
|
||||
else
|
||||
{ /* throw the strange code */
|
||||
len--;
|
||||
}
|
||||
}
|
||||
@@ -92,39 +95,40 @@ mic2gb18030(unsigned char *mic, unsigned char *p, int len)
|
||||
{
|
||||
len -= pg_mic_mblen(mic++);
|
||||
|
||||
if (c1 <= 0x7f) /*ASCII*/
|
||||
{
|
||||
if (c1 <= 0x7f) /* ASCII */
|
||||
*p++ = c1;
|
||||
}
|
||||
else if (c1 >= 0x81 && c1 <= 0xfe)
|
||||
{
|
||||
{
|
||||
c2 = *mic++;
|
||||
|
||||
if((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfe)){
|
||||
|
||||
if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfe))
|
||||
{
|
||||
*p++ = c1;
|
||||
*p++ = c2;
|
||||
}
|
||||
else if(c2 >= 0x30 && c2 <= 0x39){
|
||||
else if (c2 >= 0x30 && c2 <= 0x39)
|
||||
{
|
||||
*p++ = c1;
|
||||
*p++ = c2;
|
||||
*p++ = *mic++;
|
||||
*p++ = *mic++;
|
||||
}
|
||||
else{
|
||||
}
|
||||
else
|
||||
{
|
||||
mic--;
|
||||
pg_print_bogus_char(&mic, &p);
|
||||
mic--;
|
||||
pg_print_bogus_char(&mic, &p);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
mic--;
|
||||
pg_print_bogus_char(&mic, &p);
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -387,7 +391,7 @@ UtfToLocal(unsigned char *utf, unsigned char *iso,
|
||||
*/
|
||||
void
|
||||
LocalToUtf(unsigned char *iso, unsigned char *utf,
|
||||
pg_local_to_utf *map, int size, int encoding, int len)
|
||||
pg_local_to_utf *map, int size, int encoding, int len)
|
||||
{
|
||||
unsigned int iiso;
|
||||
int l;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ ascii_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SQL_ASCII);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -53,7 +53,7 @@ mic_to_ascii(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_SQL_ASCII);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -79,12 +79,12 @@ static void mic2win1251(unsigned char *mic, unsigned char *p, int len);
|
||||
static void alt2mic(unsigned char *l, unsigned char *p, int len);
|
||||
static void mic2alt(unsigned char *mic, unsigned char *p, int len);
|
||||
|
||||
Datum
|
||||
Datum
|
||||
koi8r_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -95,12 +95,12 @@ koi8r_to_mic(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
mic_to_koi8r(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
|
||||
@@ -116,7 +116,7 @@ iso_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -132,7 +132,7 @@ mic_to_iso(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5);
|
||||
@@ -148,7 +148,7 @@ win1251_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -164,7 +164,7 @@ mic_to_win1251(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
|
||||
@@ -180,7 +180,7 @@ alt_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ALT);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -196,7 +196,7 @@ mic_to_alt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_ALT);
|
||||
@@ -212,7 +212,7 @@ koi8r_to_win1251(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
|
||||
@@ -227,12 +227,12 @@ koi8r_to_win1251(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
win1251_to_koi8r(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
|
||||
@@ -252,7 +252,7 @@ koi8r_to_alt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
|
||||
@@ -267,12 +267,12 @@ koi8r_to_alt(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
alt_to_koi8r(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ALT);
|
||||
@@ -287,12 +287,12 @@ alt_to_koi8r(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
alt_to_win1251(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ALT);
|
||||
@@ -307,12 +307,12 @@ alt_to_win1251(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
win1251_to_alt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
|
||||
@@ -327,12 +327,12 @@ win1251_to_alt(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
iso_to_koi8r(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
|
||||
@@ -347,12 +347,12 @@ iso_to_koi8r(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
koi8r_to_iso(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
|
||||
@@ -367,12 +367,12 @@ koi8r_to_iso(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
iso_to_win1251(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
|
||||
@@ -387,12 +387,12 @@ iso_to_win1251(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
win1251_to_iso(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
|
||||
@@ -407,12 +407,12 @@ win1251_to_iso(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
iso_to_alt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5);
|
||||
@@ -427,12 +427,12 @@ iso_to_alt(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
alt_to_iso(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ALT);
|
||||
@@ -627,4 +627,3 @@ mic2alt(unsigned char *mic, unsigned char *p, int len)
|
||||
|
||||
mic2latin_with_table(mic, p, len, LC_KOI8_R, koi2alt);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ euc_cn_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_CN);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -56,7 +56,7 @@ mic_to_euc_cn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_CN);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ euc_jp_to_sjis(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_JP);
|
||||
@@ -84,7 +84,7 @@ sjis_to_euc_jp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SJIS);
|
||||
@@ -104,7 +104,7 @@ euc_jp_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_JP);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -120,7 +120,7 @@ mic_to_euc_jp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_JP);
|
||||
@@ -136,7 +136,7 @@ sjis_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SJIS);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -152,7 +152,7 @@ mic_to_sjis(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_SJIS);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ euc_kr_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_KR);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -56,7 +56,7 @@ mic_to_euc_kr(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_KR);
|
||||
@@ -122,4 +122,3 @@ mic2euc_kr(unsigned char *mic, unsigned char *p, int len)
|
||||
}
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* 1999/1/15 Tatsuo Ishii
|
||||
*
|
||||
* $Id: big5.c,v 1.1 2002/07/16 09:25:05 ishii Exp $
|
||||
* $Id: big5.c,v 1.2 2002/09/04 20:31:31 momjian Exp $
|
||||
*/
|
||||
|
||||
/* can be used in either frontend or backend */
|
||||
@@ -19,7 +19,7 @@ typedef struct
|
||||
{
|
||||
unsigned short code,
|
||||
peer;
|
||||
} codes_t;
|
||||
} codes_t;
|
||||
|
||||
/* map Big5 Level 1 to CNS 11643-1992 Plane 1 */
|
||||
static codes_t big5Level1ToCnsPlane1[25] = { /* range */
|
||||
@@ -205,7 +205,7 @@ static unsigned short b2c3[][2] = {
|
||||
};
|
||||
|
||||
static unsigned short BinarySearchRange
|
||||
(codes_t *array, int high, unsigned short code)
|
||||
(codes_t * array, int high, unsigned short code)
|
||||
{
|
||||
int low,
|
||||
mid,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ euc_tw_to_big5(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_TW);
|
||||
@@ -72,7 +72,7 @@ big5_to_euc_tw(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_BIG5);
|
||||
@@ -92,7 +92,7 @@ euc_tw_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_TW);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -108,7 +108,7 @@ mic_to_euc_tw(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_TW);
|
||||
@@ -124,7 +124,7 @@ big5_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_BIG5);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -140,7 +140,7 @@ mic_to_big5(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_BIG5);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c,v 1.2 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,12 +47,12 @@ static void mic2latin2(unsigned char *mic, unsigned char *p, int len);
|
||||
static void win12502mic(unsigned char *l, unsigned char *p, int len);
|
||||
static void mic2win1250(unsigned char *mic, unsigned char *p, int len);
|
||||
|
||||
Datum
|
||||
Datum
|
||||
latin2_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN2);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -63,12 +63,12 @@ latin2_to_mic(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
mic_to_latin2(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_LATIN2);
|
||||
@@ -84,7 +84,7 @@ win1250_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1250);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -100,7 +100,7 @@ mic_to_win1250(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN1250);
|
||||
@@ -116,7 +116,7 @@ latin2_to_win1250(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN2);
|
||||
@@ -136,7 +136,7 @@ win1250_to_latin2(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned char *buf;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1250);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,12 +47,12 @@ static void mic2latin3(unsigned char *mic, unsigned char *p, int len);
|
||||
static void latin42mic(unsigned char *l, unsigned char *p, int len);
|
||||
static void mic2latin4(unsigned char *mic, unsigned char *p, int len);
|
||||
|
||||
Datum
|
||||
Datum
|
||||
latin1_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN1);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -63,12 +63,12 @@ latin1_to_mic(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
mic_to_latin1(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_LATIN1);
|
||||
@@ -79,12 +79,12 @@ mic_to_latin1(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
latin3_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN3);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -95,12 +95,12 @@ latin3_to_mic(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
mic_to_latin3(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_LATIN3);
|
||||
@@ -111,12 +111,12 @@ mic_to_latin3(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum
|
||||
Datum
|
||||
latin4_to_mic(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN4);
|
||||
Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL);
|
||||
@@ -127,11 +127,12 @@ latin4_to_mic(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
Datum mic_to_latin4(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
mic_to_latin4(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL);
|
||||
Assert(PG_GETARG_INT32(1) == PG_LATIN4);
|
||||
@@ -172,4 +173,3 @@ mic2latin4(unsigned char *mic, unsigned char *p, int len)
|
||||
{
|
||||
mic2latin(mic, p, len, LC_ISO8859_4);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.3 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ ascii_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SQL_ASCII);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -53,7 +53,7 @@ utf8_to_ascii(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_SQL_ASCII);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ big5_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_BIG5);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -55,7 +55,7 @@ utf8_to_big5(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_BIG5);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -51,14 +51,14 @@ utf8_to_koi8r(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_KOI8R);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmap_KOI8R,
|
||||
sizeof(ULmap_KOI8R) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmap_KOI8R,
|
||||
sizeof(ULmap_KOI8R) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -68,14 +68,14 @@ koi8r_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_KOI8R);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapKOI8R,
|
||||
sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len);
|
||||
LocalToUtf(src, dest, LUmapKOI8R,
|
||||
sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -85,14 +85,14 @@ utf8_to_win1251(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN1251);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmap_WIN1251,
|
||||
sizeof(ULmap_WIN1251) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmap_WIN1251,
|
||||
sizeof(ULmap_WIN1251) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -102,14 +102,14 @@ win1251_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1251);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapWIN1251,
|
||||
sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len);
|
||||
LocalToUtf(src, dest, LUmapWIN1251,
|
||||
sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -119,14 +119,14 @@ utf8_to_alt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_ALT);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmap_ALT,
|
||||
sizeof(ULmap_ALT) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmap_ALT,
|
||||
sizeof(ULmap_ALT) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -136,14 +136,14 @@ alt_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_ALT);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapALT,
|
||||
sizeof(LUmapALT) / sizeof(pg_local_to_utf), PG_ALT, len);
|
||||
LocalToUtf(src, dest, LUmapALT,
|
||||
sizeof(LUmapALT) / sizeof(pg_local_to_utf), PG_ALT, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ euc_cn_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_CN);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_CN,
|
||||
sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
|
||||
sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_euc_cn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_CN);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ euc_jp_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_JP);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_JP,
|
||||
sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
|
||||
sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_euc_jp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_JP);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ euc_kr_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_KR);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_KR,
|
||||
sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
|
||||
sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_euc_kr(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_KR);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ euc_tw_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_EUC_TW);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapEUC_TW,
|
||||
sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
|
||||
sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_euc_tw(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_EUC_TW);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ gb18030_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_GB18030);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapGB18030,
|
||||
sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len);
|
||||
sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_gb18030(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_GB18030);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ gbk_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_GBK);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -55,7 +55,7 @@ utf8_to_gbk(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_GBK);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -58,78 +58,79 @@ extern Datum utf8_to_iso8859(PG_FUNCTION_ARGS);
|
||||
* ----------
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
pg_enc encoding;
|
||||
pg_local_to_utf *map1; /* to UTF-8 map name */
|
||||
pg_utf_to_local *map2; /* from UTF-8 map name */
|
||||
int size1; /* size of map1 */
|
||||
int size2; /* size of map2 */
|
||||
} pg_conv_map;
|
||||
typedef struct
|
||||
{
|
||||
pg_enc encoding;
|
||||
pg_local_to_utf *map1; /* to UTF-8 map name */
|
||||
pg_utf_to_local *map2; /* from UTF-8 map name */
|
||||
int size1; /* size of map1 */
|
||||
int size2; /* size of map2 */
|
||||
} pg_conv_map;
|
||||
|
||||
static pg_conv_map maps[] = {
|
||||
{PG_SQL_ASCII}, /* SQL/ASCII */
|
||||
{PG_EUC_JP}, /* EUC for Japanese */
|
||||
{PG_EUC_CN}, /* EUC for Chinese */
|
||||
{PG_EUC_KR}, /* EUC for Korean */
|
||||
{PG_EUC_TW}, /* EUC for Taiwan */
|
||||
{PG_JOHAB}, /* EUC for Korean JOHAB */
|
||||
{PG_UTF8}, /* Unicode UTF-8 */
|
||||
{PG_MULE_INTERNAL}, /* Mule internal code */
|
||||
{PG_LATIN1}, /* ISO-8859-1 Latin 1 */
|
||||
{PG_SQL_ASCII}, /* SQL/ASCII */
|
||||
{PG_EUC_JP}, /* EUC for Japanese */
|
||||
{PG_EUC_CN}, /* EUC for Chinese */
|
||||
{PG_EUC_KR}, /* EUC for Korean */
|
||||
{PG_EUC_TW}, /* EUC for Taiwan */
|
||||
{PG_JOHAB}, /* EUC for Korean JOHAB */
|
||||
{PG_UTF8}, /* Unicode UTF-8 */
|
||||
{PG_MULE_INTERNAL}, /* Mule internal code */
|
||||
{PG_LATIN1}, /* ISO-8859-1 Latin 1 */
|
||||
{PG_LATIN2, LUmapISO8859_2, ULmapISO8859_2,
|
||||
sizeof(LUmapISO8859_2)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_2)/sizeof(pg_utf_to_local)}, /* ISO-8859-2 Latin 2 */
|
||||
sizeof(LUmapISO8859_2) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_2) / sizeof(pg_utf_to_local)}, /* ISO-8859-2 Latin 2 */
|
||||
{PG_LATIN3, LUmapISO8859_3, ULmapISO8859_3,
|
||||
sizeof(LUmapISO8859_3)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_3)/sizeof(pg_utf_to_local)}, /* ISO-8859-3 Latin 3 */
|
||||
sizeof(LUmapISO8859_3) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_3) / sizeof(pg_utf_to_local)}, /* ISO-8859-3 Latin 3 */
|
||||
{PG_LATIN4, LUmapISO8859_4, ULmapISO8859_4,
|
||||
sizeof(LUmapISO8859_4)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_4)/sizeof(pg_utf_to_local)}, /* ISO-8859-4 Latin 4 */
|
||||
sizeof(LUmapISO8859_4) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_4) / sizeof(pg_utf_to_local)}, /* ISO-8859-4 Latin 4 */
|
||||
{PG_LATIN5, LUmapISO8859_9, ULmapISO8859_9,
|
||||
sizeof(LUmapISO8859_9)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_9)/sizeof(pg_utf_to_local)}, /* ISO-8859-9 Latin 5 */
|
||||
sizeof(LUmapISO8859_9) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_9) / sizeof(pg_utf_to_local)}, /* ISO-8859-9 Latin 5 */
|
||||
{PG_LATIN6, LUmapISO8859_10, ULmapISO8859_10,
|
||||
sizeof(LUmapISO8859_10)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_10)/sizeof(pg_utf_to_local)}, /* ISO-8859-10 Latin 6 */
|
||||
sizeof(LUmapISO8859_10) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_10) / sizeof(pg_utf_to_local)}, /* ISO-8859-10 Latin 6 */
|
||||
{PG_LATIN7, LUmapISO8859_13, ULmapISO8859_13,
|
||||
sizeof(LUmapISO8859_13)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_13)/sizeof(pg_utf_to_local)}, /* ISO-8859-13 Latin 7 */
|
||||
sizeof(LUmapISO8859_13) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_13) / sizeof(pg_utf_to_local)}, /* ISO-8859-13 Latin 7 */
|
||||
{PG_LATIN8, LUmapISO8859_14, ULmapISO8859_14,
|
||||
sizeof(LUmapISO8859_14)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_14)/sizeof(pg_utf_to_local)}, /* ISO-8859-14 Latin 8 */
|
||||
sizeof(LUmapISO8859_14) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_14) / sizeof(pg_utf_to_local)}, /* ISO-8859-14 Latin 8 */
|
||||
{PG_LATIN9, LUmapISO8859_2, ULmapISO8859_2,
|
||||
sizeof(LUmapISO8859_15)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_15)/sizeof(pg_utf_to_local)}, /* ISO-8859-15 Latin 9 */
|
||||
sizeof(LUmapISO8859_15) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_15) / sizeof(pg_utf_to_local)}, /* ISO-8859-15 Latin 9 */
|
||||
{PG_LATIN10, LUmapISO8859_16, ULmapISO8859_16,
|
||||
sizeof(LUmapISO8859_16)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_16)/sizeof(pg_utf_to_local)}, /* ISO-8859-16 Latin 10 */
|
||||
{PG_WIN1256}, /* windows-1256 */
|
||||
sizeof(LUmapISO8859_16) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_16) / sizeof(pg_utf_to_local)}, /* ISO-8859-16 Latin 10 */
|
||||
{PG_WIN1256}, /* windows-1256 */
|
||||
{PG_TCVN}, /* TCVN (Windows-1258) */
|
||||
{PG_WIN874}, /* windows-874 */
|
||||
{PG_KOI8R}, /* KOI8-R */
|
||||
{PG_WIN1251}, /* windows-1251 (was: WIN) */
|
||||
{PG_ALT}, /* (MS-DOS CP866) */
|
||||
{PG_ISO_8859_5, LUmapISO8859_5, ULmapISO8859_5,
|
||||
sizeof(LUmapISO8859_5)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_5)/sizeof(pg_utf_to_local)}, /* ISO-8859-5 */
|
||||
sizeof(LUmapISO8859_5) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_5) / sizeof(pg_utf_to_local)}, /* ISO-8859-5 */
|
||||
{PG_ISO_8859_6, LUmapISO8859_6, ULmapISO8859_6,
|
||||
sizeof(LUmapISO8859_6)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_6)/sizeof(pg_utf_to_local)}, /* ISO-8859-6 */
|
||||
sizeof(LUmapISO8859_6) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_6) / sizeof(pg_utf_to_local)}, /* ISO-8859-6 */
|
||||
{PG_ISO_8859_7, LUmapISO8859_7, ULmapISO8859_7,
|
||||
sizeof(LUmapISO8859_7)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_7)/sizeof(pg_utf_to_local)}, /* ISO-8859-7 */
|
||||
sizeof(LUmapISO8859_7) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_7) / sizeof(pg_utf_to_local)}, /* ISO-8859-7 */
|
||||
{PG_ISO_8859_8, LUmapISO8859_8, ULmapISO8859_8,
|
||||
sizeof(LUmapISO8859_8)/sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_8)/sizeof(pg_utf_to_local)}, /* ISO-8859-8 */
|
||||
sizeof(LUmapISO8859_8) / sizeof(pg_local_to_utf),
|
||||
sizeof(ULmapISO8859_8) / sizeof(pg_utf_to_local)}, /* ISO-8859-8 */
|
||||
};
|
||||
|
||||
|
||||
Datum
|
||||
iso8859_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int encoding = PG_GETARG_INT32(0);
|
||||
int encoding = PG_GETARG_INT32(0);
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
@@ -142,10 +143,10 @@ iso8859_to_utf8(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
utf8_to_iso8859(PG_FUNCTION_ARGS)
|
||||
{
|
||||
int encoding = PG_GETARG_INT32(1);
|
||||
int encoding = PG_GETARG_INT32(1);
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ iso8859_1_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned short c;
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_LATIN1);
|
||||
@@ -64,7 +64,7 @@ utf8_to_iso8859_1(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
unsigned short c,
|
||||
c1,
|
||||
c2;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,14 +38,14 @@ johab_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_JOHAB);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapJOHAB,
|
||||
sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len);
|
||||
sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ utf8_to_johab(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_JOHAB);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ sjis_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_SJIS);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -55,7 +55,7 @@ utf8_to_sjis(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_SJIS);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Attic/utf8_and_tcvn.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Attic/utf8_and_tcvn.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ tcvn_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_TCVN);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -55,7 +55,7 @@ utf8_to_tcvn(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_TCVN);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ uhc_to_utf8(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UHC);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
@@ -55,7 +55,7 @@ utf8_to_uhc(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UHC);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Attic/utf8_and_win1250.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Attic/utf8_and_win1250.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -39,14 +39,14 @@ utf_to_win1250(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN1250);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapWIN1250,
|
||||
sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmapWIN1250,
|
||||
sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ win1250_to_utf(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1250);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Attic/utf8_and_win1256.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Attic/utf8_and_win1256.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -39,14 +39,14 @@ utf_to_win1256(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN1256);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapWIN1256,
|
||||
sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmapWIN1256,
|
||||
sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ win1256_to_utf(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN1256);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/Attic/utf8_and_win874.c,v 1.2 2002/08/22 00:01:45 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/Attic/utf8_and_win874.c,v 1.3 2002/09/04 20:31:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -39,14 +39,14 @@ utf_to_win874(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_UTF8);
|
||||
Assert(PG_GETARG_INT32(1) == PG_WIN874);
|
||||
Assert(len > 0);
|
||||
|
||||
UtfToLocal(src, dest, ULmapWIN874,
|
||||
sizeof(ULmapWIN874) / sizeof(pg_utf_to_local), len);
|
||||
UtfToLocal(src, dest, ULmapWIN874,
|
||||
sizeof(ULmapWIN874) / sizeof(pg_utf_to_local), len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
@@ -56,14 +56,14 @@ win874_to_utf(PG_FUNCTION_ARGS)
|
||||
{
|
||||
unsigned char *src = PG_GETARG_CSTRING(2);
|
||||
unsigned char *dest = PG_GETARG_CSTRING(3);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
int len = PG_GETARG_INT32(4);
|
||||
|
||||
Assert(PG_GETARG_INT32(0) == PG_WIN874);
|
||||
Assert(PG_GETARG_INT32(1) == PG_UTF8);
|
||||
Assert(len > 0);
|
||||
|
||||
LocalToUtf(src, dest, LUmapWIN874,
|
||||
sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len);
|
||||
sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len);
|
||||
|
||||
PG_RETURN_INT32(0);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Encoding names and routines for work with it. All
|
||||
* in this file is shared bedween FE and BE.
|
||||
*
|
||||
* $Id: encnames.c,v 1.9 2002/09/03 21:45:43 petere Exp $
|
||||
* $Id: encnames.c,v 1.10 2002/09/04 20:31:31 momjian Exp $
|
||||
*/
|
||||
#ifdef FRONTEND
|
||||
#include "postgres_fe.h"
|
||||
@@ -55,12 +55,12 @@ pg_encname pg_encname_tbl[] =
|
||||
* for Japanese, stdandard OSF */
|
||||
{
|
||||
"euckr", PG_EUC_KR
|
||||
}, /* EUC-KR; Extended Unix Code for
|
||||
* Korean , KS X 1001 standard */
|
||||
}, /* EUC-KR; Extended Unix Code for Korean ,
|
||||
* KS X 1001 standard */
|
||||
{
|
||||
"euctw", PG_EUC_TW
|
||||
}, /* EUC-TW; Extended Unix Code for
|
||||
|
||||
*
|
||||
* traditional Chinese */
|
||||
{
|
||||
"gb18030", PG_GB18030
|
||||
@@ -171,7 +171,7 @@ pg_encname pg_encname_tbl[] =
|
||||
"tcvn", PG_TCVN
|
||||
}, /* TCVN; Vietnamese TCVN-5712 */
|
||||
{
|
||||
"tcvn5712",PG_TCVN
|
||||
"tcvn5712", PG_TCVN
|
||||
}, /* alias for TCVN */
|
||||
{
|
||||
"uhc", PG_UHC
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* client encoding and server internal encoding.
|
||||
* (currently mule internal code (mic) is used)
|
||||
* Tatsuo Ishii
|
||||
* $Id: mbutils.c,v 1.34 2002/09/03 21:45:43 petere Exp $
|
||||
* $Id: mbutils.c,v 1.35 2002/09/04 20:31:31 momjian Exp $
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "access/xact.h"
|
||||
@@ -27,15 +27,15 @@ static pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];
|
||||
* allocated in TopMemoryContext so that it survives outside
|
||||
* transactions. See SetClientEncoding() for more details.
|
||||
*/
|
||||
static FmgrInfo *ToServerConvPorc = NULL;
|
||||
static FmgrInfo *ToClientConvPorc = NULL;
|
||||
static FmgrInfo *ToServerConvPorc = NULL;
|
||||
static FmgrInfo *ToClientConvPorc = NULL;
|
||||
|
||||
/* Internal functions */
|
||||
static unsigned char *
|
||||
perform_default_encoding_conversion(unsigned char *src, int len, bool is_client_to_server);
|
||||
perform_default_encoding_conversion(unsigned char *src, int len, bool is_client_to_server);
|
||||
|
||||
static int
|
||||
cliplen(const unsigned char *str, int len, int limit);
|
||||
cliplen(const unsigned char *str, int len, int limit);
|
||||
|
||||
/*
|
||||
* Set the client encoding and save fmgrinfo for the converion
|
||||
@@ -46,9 +46,10 @@ int
|
||||
SetClientEncoding(int encoding, bool doit)
|
||||
{
|
||||
int current_server_encoding;
|
||||
Oid to_server_proc, to_client_proc;
|
||||
FmgrInfo *to_server = NULL;
|
||||
FmgrInfo *to_client = NULL;
|
||||
Oid to_server_proc,
|
||||
to_client_proc;
|
||||
FmgrInfo *to_server = NULL;
|
||||
FmgrInfo *to_client = NULL;
|
||||
MemoryContext oldcontext;
|
||||
|
||||
current_server_encoding = GetDatabaseEncoding();
|
||||
@@ -57,15 +58,15 @@ SetClientEncoding(int encoding, bool doit)
|
||||
return (-1);
|
||||
|
||||
if (current_server_encoding == encoding ||
|
||||
(current_server_encoding == PG_SQL_ASCII || encoding == PG_SQL_ASCII))
|
||||
(current_server_encoding == PG_SQL_ASCII || encoding == PG_SQL_ASCII))
|
||||
{
|
||||
ClientEncoding = &pg_enc2name_tbl[encoding];
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* XXX We cannot use FindDefaultConversionProc() while in
|
||||
* bootstrap or initprocessing mode since namespace functions will
|
||||
* not work.
|
||||
/*
|
||||
* XXX We cannot use FindDefaultConversionProc() while in bootstrap or
|
||||
* initprocessing mode since namespace functions will not work.
|
||||
*/
|
||||
if (IsTransactionState())
|
||||
{
|
||||
@@ -76,8 +77,8 @@ SetClientEncoding(int encoding, bool doit)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* load the fmgr info into TopMemoryContext so that it
|
||||
* survives outside transaction.
|
||||
* load the fmgr info into TopMemoryContext so that it survives
|
||||
* outside transaction.
|
||||
*/
|
||||
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
|
||||
to_server = palloc(sizeof(FmgrInfo));
|
||||
@@ -94,7 +95,7 @@ SetClientEncoding(int encoding, bool doit)
|
||||
{
|
||||
ClientEncoding = &pg_enc2name_tbl[encoding];
|
||||
|
||||
if(ToServerConvPorc != NULL)
|
||||
if (ToServerConvPorc != NULL)
|
||||
{
|
||||
if (ToServerConvPorc->fn_extra)
|
||||
pfree(ToServerConvPorc->fn_extra);
|
||||
@@ -102,7 +103,7 @@ SetClientEncoding(int encoding, bool doit)
|
||||
}
|
||||
ToServerConvPorc = to_server;
|
||||
|
||||
if(ToClientConvPorc != NULL)
|
||||
if (ToClientConvPorc != NULL)
|
||||
{
|
||||
if (ToClientConvPorc->fn_extra)
|
||||
pfree(ToClientConvPorc->fn_extra);
|
||||
@@ -152,11 +153,11 @@ pg_do_encoding_conversion(unsigned char *src, int len,
|
||||
int src_encoding, int dest_encoding)
|
||||
{
|
||||
unsigned char *result;
|
||||
Oid proc;
|
||||
Oid proc;
|
||||
|
||||
if (!IsTransactionState())
|
||||
return src;
|
||||
|
||||
|
||||
if (src_encoding == dest_encoding)
|
||||
return src;
|
||||
|
||||
@@ -171,13 +172,14 @@ pg_do_encoding_conversion(unsigned char *src, int len,
|
||||
return src;
|
||||
}
|
||||
|
||||
/* XXX we shoud avoid throwing errors in OidFuctionCall. Otherwise
|
||||
* we are going into inifinite loop! So we have to make sure that
|
||||
* the function exists before calling OidFunctionCall.
|
||||
/*
|
||||
* XXX we shoud avoid throwing errors in OidFuctionCall. Otherwise we
|
||||
* are going into inifinite loop! So we have to make sure that the
|
||||
* function exists before calling OidFunctionCall.
|
||||
*/
|
||||
if (!SearchSysCacheExists(PROCOID,
|
||||
ObjectIdGetDatum(proc),
|
||||
0, 0, 0))
|
||||
ObjectIdGetDatum(proc),
|
||||
0, 0, 0))
|
||||
{
|
||||
elog(LOG, "default conversion proc %u for %s to %s not found in pg_proc",
|
||||
proc,
|
||||
@@ -204,17 +206,17 @@ pg_do_encoding_conversion(unsigned char *src, int len,
|
||||
Datum
|
||||
pg_convert(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum string = PG_GETARG_DATUM(0);
|
||||
Datum dest_encoding_name = PG_GETARG_DATUM(1);
|
||||
Datum src_encoding_name = DirectFunctionCall1(
|
||||
namein, CStringGetDatum(DatabaseEncoding->name));
|
||||
Datum result;
|
||||
Datum string = PG_GETARG_DATUM(0);
|
||||
Datum dest_encoding_name = PG_GETARG_DATUM(1);
|
||||
Datum src_encoding_name = DirectFunctionCall1(
|
||||
namein, CStringGetDatum(DatabaseEncoding->name));
|
||||
Datum result;
|
||||
|
||||
result = DirectFunctionCall3(
|
||||
pg_convert2, string, src_encoding_name, dest_encoding_name);
|
||||
pg_convert2, string, src_encoding_name, dest_encoding_name);
|
||||
|
||||
/* free memory allocated by namein */
|
||||
pfree((void *)src_encoding_name);
|
||||
pfree((void *) src_encoding_name);
|
||||
|
||||
PG_RETURN_TEXT_P(result);
|
||||
}
|
||||
@@ -235,7 +237,7 @@ pg_convert2(PG_FUNCTION_ARGS)
|
||||
unsigned char *result;
|
||||
text *retval;
|
||||
unsigned char *str;
|
||||
int len;
|
||||
int len;
|
||||
|
||||
if (src_encoding < 0)
|
||||
elog(ERROR, "Invalid source encoding name %s", src_encoding_name);
|
||||
@@ -252,9 +254,11 @@ pg_convert2(PG_FUNCTION_ARGS)
|
||||
if (result == NULL)
|
||||
elog(ERROR, "Encoding conversion failed");
|
||||
|
||||
/* build text data type structre. we cannot use textin() here,
|
||||
since textin assumes that input string encoding is same as
|
||||
database encoding. */
|
||||
/*
|
||||
* build text data type structre. we cannot use textin() here, since
|
||||
* textin assumes that input string encoding is same as database
|
||||
* encoding.
|
||||
*/
|
||||
len = strlen(result) + VARHDRSZ;
|
||||
retval = palloc(len);
|
||||
VARATT_SIZEP(retval) = len;
|
||||
@@ -262,7 +266,7 @@ pg_convert2(PG_FUNCTION_ARGS)
|
||||
|
||||
if (result != str)
|
||||
pfree(result);
|
||||
pfree(str);
|
||||
pfree(str);
|
||||
|
||||
/* free memory if allocated by the toaster */
|
||||
PG_FREE_IF_COPY(string, 0);
|
||||
@@ -301,18 +305,19 @@ pg_server_to_client(unsigned char *s, int len)
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform default encoding conversion using cached FmgrInfo. Since
|
||||
* this function does not access database at all, it is safe to call
|
||||
* outside transactions. Explicit setting client encoding required
|
||||
* before calling this function. Otherwise no conversion is
|
||||
* performed.
|
||||
* Perform default encoding conversion using cached FmgrInfo. Since
|
||||
* this function does not access database at all, it is safe to call
|
||||
* outside transactions. Explicit setting client encoding required
|
||||
* before calling this function. Otherwise no conversion is
|
||||
* performed.
|
||||
*/
|
||||
static unsigned char *
|
||||
perform_default_encoding_conversion(unsigned char *src, int len, bool is_client_to_server)
|
||||
{
|
||||
unsigned char *result;
|
||||
int src_encoding, dest_encoding;
|
||||
FmgrInfo *flinfo;
|
||||
int src_encoding,
|
||||
dest_encoding;
|
||||
FmgrInfo *flinfo;
|
||||
|
||||
if (is_client_to_server)
|
||||
{
|
||||
@@ -376,7 +381,7 @@ pg_mbstrlen(const unsigned char *mbstr)
|
||||
|
||||
/* optimization for single byte encoding */
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
return strlen((char *)mbstr);
|
||||
return strlen((char *) mbstr);
|
||||
|
||||
while (*mbstr)
|
||||
{
|
||||
@@ -506,9 +511,9 @@ pg_client_encoding(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
static int
|
||||
cliplen(const unsigned char *str, int len, int limit)
|
||||
cliplen(const unsigned char *str, int len, int limit)
|
||||
{
|
||||
int l = 0;
|
||||
int l = 0;
|
||||
const unsigned char *s;
|
||||
|
||||
for (s = str; *s; s++, l++)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* conversion functions between pg_wchar and multibyte streams.
|
||||
* Tatsuo Ishii
|
||||
* $Id: wchar.c,v 1.29 2002/09/03 21:45:43 petere Exp $
|
||||
* $Id: wchar.c,v 1.30 2002/09/04 20:31:31 momjian Exp $
|
||||
*
|
||||
* WIN1250 client encoding updated by Pavel Behal
|
||||
*
|
||||
@@ -511,30 +511,31 @@ pg_uhc_mblen(const unsigned char *s)
|
||||
}
|
||||
|
||||
/*
|
||||
* * GB18030
|
||||
* * Added by Bill Huang <bhuang@redhat.com>,<bill_huanghb@ybb.ne.jp>
|
||||
* */
|
||||
* * GB18030
|
||||
* * Added by Bill Huang <bhuang@redhat.com>,<bill_huanghb@ybb.ne.jp>
|
||||
* */
|
||||
static int
|
||||
pg_gb18030_mblen(const unsigned char *s)
|
||||
{
|
||||
int len;
|
||||
if (*s <= 0x7f)
|
||||
{ /* ASCII */
|
||||
len = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((*(s+1) >= 0x40 && *(s+1) <= 0x7e)|| (*(s+1) >= 0x80 && *(s+1) <= 0xfe))
|
||||
len = 2;
|
||||
else if(*(s+1) >= 0x30 && *(s+1) <= 0x39)
|
||||
len = 4;
|
||||
else
|
||||
len = 2;
|
||||
}
|
||||
return (len);
|
||||
int len;
|
||||
|
||||
if (*s <= 0x7f)
|
||||
{ /* ASCII */
|
||||
len = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((*(s + 1) >= 0x40 && *(s + 1) <= 0x7e) || (*(s + 1) >= 0x80 && *(s + 1) <= 0xfe))
|
||||
len = 2;
|
||||
else if (*(s + 1) >= 0x30 && *(s + 1) <= 0x39)
|
||||
len = 4;
|
||||
else
|
||||
len = 2;
|
||||
}
|
||||
return (len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
pg_wchar_tbl pg_wchar_table[] = {
|
||||
{pg_ascii2wchar_with_len, pg_ascii_mblen, 1}, /* 0; PG_SQL_ASCII */
|
||||
{pg_eucjp2wchar_with_len, pg_eucjp_mblen, 3}, /* 1; PG_EUC_JP */
|
||||
@@ -543,7 +544,7 @@ pg_wchar_tbl pg_wchar_table[] = {
|
||||
{pg_euctw2wchar_with_len, pg_euctw_mblen, 3}, /* 4; PG_EUC_TW */
|
||||
{pg_johab2wchar_with_len, pg_johab_mblen, 3}, /* 5; PG_JOHAB */
|
||||
{pg_utf2wchar_with_len, pg_utf_mblen, 3}, /* 6; PG_UNICODE */
|
||||
{pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 7; PG_MULE_INTERNAL */
|
||||
{pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 7; PG_MULE_INTERNAL */
|
||||
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 8; PG_LATIN1 */
|
||||
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 9; PG_LATIN2 */
|
||||
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 10; PG_LATIN3 */
|
||||
@@ -569,7 +570,7 @@ pg_wchar_tbl pg_wchar_table[] = {
|
||||
{0, pg_gbk_mblen, 2}, /* 30; PG_GBK */
|
||||
{0, pg_uhc_mblen, 2}, /* 31; PG_UHC */
|
||||
{pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 32; PG_WIN1250 */
|
||||
{0, pg_gb18030_mblen, 2} /* 33; PG_GB18030 */
|
||||
{0, pg_gb18030_mblen, 2} /* 33; PG_GB18030 */
|
||||
};
|
||||
|
||||
/* returns the byte length of a word for mule internal code */
|
||||
|
||||
Reference in New Issue
Block a user