Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commited45a53

Browse files
committed
Back-patch addition of pg_wchar-to-multibyte conversion functionality.
Back-patch of commits72dd629,f6a05fd, and60e9c22.This is needed to support fixing the regex prefix extraction bug inback branches.
1 parent892a8d0 commited45a53

File tree

3 files changed

+259
-49
lines changed

3 files changed

+259
-49
lines changed

‎src/backend/utils/mb/mbutils.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,28 @@ pg_encoding_mb2wchar_with_len(int encoding,
710710
return (*pg_wchar_table[encoding].mb2wchar_with_len) ((constunsignedchar*)from,to,len);
711711
}
712712

713+
/* convert a wchar string to a multibyte */
714+
int
715+
pg_wchar2mb(constpg_wchar*from,char*to)
716+
{
717+
return (*pg_wchar_table[DatabaseEncoding->encoding].wchar2mb_with_len) (from, (unsignedchar*)to,pg_wchar_strlen(from));
718+
}
719+
720+
/* convert a wchar string to a multibyte with a limited length */
721+
int
722+
pg_wchar2mb_with_len(constpg_wchar*from,char*to,intlen)
723+
{
724+
return (*pg_wchar_table[DatabaseEncoding->encoding].wchar2mb_with_len) (from, (unsignedchar*)to,len);
725+
}
726+
727+
/* same, with any encoding */
728+
int
729+
pg_encoding_wchar2mb_with_len(intencoding,
730+
constpg_wchar*from,char*to,intlen)
731+
{
732+
return (*pg_wchar_table[encoding].wchar2mb_with_len) (from, (unsignedchar*)to,len);
733+
}
734+
713735
/* returns the byte length of a multibyte character */
714736
int
715737
pg_mblen(constchar*mbstr)

‎src/backend/utils/mb/wchar.c

Lines changed: 210 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ pg_euc2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
9999
*to |=*from++;
100100
len-=2;
101101
}
102-
else
103-
/* must be ASCII */
102+
else/* must be ASCII */
104103
{
105104
*to=*from++;
106105
len--;
@@ -339,6 +338,55 @@ pg_euctw_dsplen(const unsigned char *s)
339338
returnlen;
340339
}
341340

341+
/*
342+
* Convert pg_wchar to EUC_* encoding.
343+
* caller must allocate enough space for "to", including a trailing zero!
344+
* len: length of from.
345+
* "from" not necessarily null terminated.
346+
*/
347+
staticint
348+
pg_wchar2euc_with_len(constpg_wchar*from,unsignedchar*to,intlen)
349+
{
350+
intcnt=0;
351+
352+
while (len>0&&*from)
353+
{
354+
unsignedcharc;
355+
356+
if ((c= (*from >>24)))
357+
{
358+
*to++=c;
359+
*to++= (*from >>16)&0xff;
360+
*to++= (*from >>8)&0xff;
361+
*to++=*from&0xff;
362+
cnt+=4;
363+
}
364+
elseif ((c= (*from >>16)))
365+
{
366+
*to++=c;
367+
*to++= (*from >>8)&0xff;
368+
*to++=*from&0xff;
369+
cnt+=3;
370+
}
371+
elseif ((c= (*from >>8)))
372+
{
373+
*to++=c;
374+
*to++=*from&0xff;
375+
cnt+=2;
376+
}
377+
else
378+
{
379+
*to++=*from;
380+
cnt++;
381+
}
382+
from++;
383+
len--;
384+
}
385+
*to=0;
386+
returncnt;
387+
}
388+
389+
342390
/*
343391
* JOHAB
344392
*/
@@ -453,6 +501,31 @@ unicode_to_utf8(pg_wchar c, unsigned char *utf8string)
453501
returnutf8string;
454502
}
455503

504+
/*
505+
* Trivial conversion from pg_wchar to UTF-8.
506+
* caller should allocate enough space for "to"
507+
* len: length of from.
508+
* "from" not necessarily null terminated.
509+
*/
510+
staticint
511+
pg_wchar2utf_with_len(constpg_wchar*from,unsignedchar*to,intlen)
512+
{
513+
intcnt=0;
514+
515+
while (len>0&&*from)
516+
{
517+
intchar_len;
518+
519+
unicode_to_utf8(*from,to);
520+
char_len=pg_utf_mblen(to);
521+
cnt+=char_len;
522+
to+=char_len;
523+
from++;
524+
len--;
525+
}
526+
*to=0;
527+
returncnt;
528+
}
456529

457530
/*
458531
* Return the byte length of a UTF8 character pointed to by s
@@ -719,6 +792,77 @@ pg_mule2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
719792
returncnt;
720793
}
721794

795+
/*
796+
* convert pg_wchar to mule internal code
797+
* caller should allocate enough space for "to"
798+
* len: length of from.
799+
* "from" not necessarily null terminated.
800+
*/
801+
staticint
802+
pg_wchar2mule_with_len(constpg_wchar*from,unsignedchar*to,intlen)
803+
{
804+
intcnt=0;
805+
806+
while (len>0&&*from)
807+
{
808+
unsignedcharlb;
809+
810+
lb= (*from >>16)&0xff;
811+
if (IS_LC1(lb))
812+
{
813+
*to++=lb;
814+
*to++=*from&0xff;
815+
cnt+=2;
816+
}
817+
elseif (IS_LC2(lb))
818+
{
819+
*to++=lb;
820+
*to++= (*from >>8)&0xff;
821+
*to++=*from&0xff;
822+
cnt+=3;
823+
}
824+
elseif (IS_LCPRV1_A_RANGE(lb))
825+
{
826+
*to++=LCPRV1_A;
827+
*to++=lb;
828+
*to++=*from&0xff;
829+
cnt+=3;
830+
}
831+
elseif (IS_LCPRV1_B_RANGE(lb))
832+
{
833+
*to++=LCPRV1_B;
834+
*to++=lb;
835+
*to++=*from&0xff;
836+
cnt+=3;
837+
}
838+
elseif (IS_LCPRV2_A_RANGE(lb))
839+
{
840+
*to++=LCPRV2_A;
841+
*to++=lb;
842+
*to++= (*from >>8)&0xff;
843+
*to++=*from&0xff;
844+
cnt+=4;
845+
}
846+
elseif (IS_LCPRV2_B_RANGE(lb))
847+
{
848+
*to++=LCPRV2_B;
849+
*to++=lb;
850+
*to++= (*from >>8)&0xff;
851+
*to++=*from&0xff;
852+
cnt+=4;
853+
}
854+
else
855+
{
856+
*to++=*from&0xff;
857+
cnt+=1;
858+
}
859+
from++;
860+
len--;
861+
}
862+
*to=0;
863+
returncnt;
864+
}
865+
722866
int
723867
pg_mule_mblen(constunsignedchar*s)
724868
{
@@ -774,6 +918,28 @@ pg_latin12wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
774918
returncnt;
775919
}
776920

921+
/*
922+
* Trivial conversion from pg_wchar to single byte encoding. Just ignores
923+
* high bits.
924+
* caller should allocate enough space for "to"
925+
* len: length of from.
926+
* "from" not necessarily null terminated.
927+
*/
928+
staticint
929+
pg_wchar2single_with_len(constpg_wchar*from,unsignedchar*to,intlen)
930+
{
931+
intcnt=0;
932+
933+
while (len>0&&*from)
934+
{
935+
*to++=*from++;
936+
len--;
937+
cnt++;
938+
}
939+
*to=0;
940+
returncnt;
941+
}
942+
777943
staticint
778944
pg_latin1_mblen(constunsignedchar*s)
779945
{
@@ -1341,48 +1507,48 @@ pg_utf8_islegal(const unsigned char *source, int length)
13411507
*-------------------------------------------------------------------
13421508
*/
13431509
pg_wchar_tblpg_wchar_table[]= {
1344-
{pg_ascii2wchar_with_len,pg_ascii_mblen,pg_ascii_dsplen,pg_ascii_verifier,1},/* PG_SQL_ASCII */
1345-
{pg_eucjp2wchar_with_len,pg_eucjp_mblen,pg_eucjp_dsplen,pg_eucjp_verifier,3},/* PG_EUC_JP */
1346-
{pg_euccn2wchar_with_len,pg_euccn_mblen,pg_euccn_dsplen,pg_euccn_verifier,2},/* PG_EUC_CN */
1347-
{pg_euckr2wchar_with_len,pg_euckr_mblen,pg_euckr_dsplen,pg_euckr_verifier,3},/* PG_EUC_KR */
1348-
{pg_euctw2wchar_with_len,pg_euctw_mblen,pg_euctw_dsplen,pg_euctw_verifier,4},/* PG_EUC_TW */
1349-
{pg_eucjp2wchar_with_len,pg_eucjp_mblen,pg_eucjp_dsplen,pg_eucjp_verifier,3},/* PG_EUC_JIS_2004 */
1350-
{pg_utf2wchar_with_len,pg_utf_mblen,pg_utf_dsplen,pg_utf8_verifier,4},/* PG_UTF8 */
1351-
{pg_mule2wchar_with_len,pg_mule_mblen,pg_mule_dsplen,pg_mule_verifier,4},/* PG_MULE_INTERNAL */
1352-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN1 */
1353-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN2 */
1354-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN3 */
1355-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN4 */
1356-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN5 */
1357-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN6 */
1358-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN7 */
1359-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN8 */
1360-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN9 */
1361-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN10 */
1362-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1256 */
1363-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1258 */
1364-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN866 */
1365-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN874 */
1366-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_KOI8R */
1367-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1251 */
1368-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1252 */
1369-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* ISO-8859-5 */
1370-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* ISO-8859-6 */
1371-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* ISO-8859-7 */
1372-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* ISO-8859-8 */
1373-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1250 */
1374-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1253 */
1375-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1254 */
1376-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1255 */
1377-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1257 */
1378-
{pg_latin12wchar_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_KOI8U */
1379-
{0,pg_sjis_mblen,pg_sjis_dsplen,pg_sjis_verifier,2},/* PG_SJIS */
1380-
{0,pg_big5_mblen,pg_big5_dsplen,pg_big5_verifier,2},/* PG_BIG5 */
1381-
{0,pg_gbk_mblen,pg_gbk_dsplen,pg_gbk_verifier,2},/* PG_GBK */
1382-
{0,pg_uhc_mblen,pg_uhc_dsplen,pg_uhc_verifier,2},/* PG_UHC */
1383-
{0,pg_gb18030_mblen,pg_gb18030_dsplen,pg_gb18030_verifier,4},/* PG_GB18030 */
1384-
{0,pg_johab_mblen,pg_johab_dsplen,pg_johab_verifier,3},/* PG_JOHAB */
1385-
{0,pg_sjis_mblen,pg_sjis_dsplen,pg_sjis_verifier,2}/* PG_SHIFT_JIS_2004 */
1510+
{pg_ascii2wchar_with_len,pg_wchar2single_with_len,pg_ascii_mblen,pg_ascii_dsplen,pg_ascii_verifier,1},/* PG_SQL_ASCII */
1511+
{pg_eucjp2wchar_with_len,pg_wchar2euc_with_len,pg_eucjp_mblen,pg_eucjp_dsplen,pg_eucjp_verifier,3},/* PG_EUC_JP */
1512+
{pg_euccn2wchar_with_len,pg_wchar2euc_with_len,pg_euccn_mblen,pg_euccn_dsplen,pg_euccn_verifier,2},/* PG_EUC_CN */
1513+
{pg_euckr2wchar_with_len,pg_wchar2euc_with_len,pg_euckr_mblen,pg_euckr_dsplen,pg_euckr_verifier,3},/* PG_EUC_KR */
1514+
{pg_euctw2wchar_with_len,pg_wchar2euc_with_len,pg_euctw_mblen,pg_euctw_dsplen,pg_euctw_verifier,4},/* PG_EUC_TW */
1515+
{pg_eucjp2wchar_with_len,pg_wchar2euc_with_len,pg_eucjp_mblen,pg_eucjp_dsplen,pg_eucjp_verifier,3},/* PG_EUC_JIS_2004 */
1516+
{pg_utf2wchar_with_len,pg_wchar2utf_with_len,pg_utf_mblen,pg_utf_dsplen,pg_utf8_verifier,4},/* PG_UTF8 */
1517+
{pg_mule2wchar_with_len,pg_wchar2mule_with_len,pg_mule_mblen,pg_mule_dsplen,pg_mule_verifier,4},/* PG_MULE_INTERNAL */
1518+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN1 */
1519+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN2 */
1520+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN3 */
1521+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN4 */
1522+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN5 */
1523+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN6 */
1524+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN7 */
1525+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN8 */
1526+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN9 */
1527+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_LATIN10 */
1528+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1256 */
1529+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1258 */
1530+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN866 */
1531+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN874 */
1532+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_KOI8R */
1533+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1251 */
1534+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1252 */
1535+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* ISO-8859-5 */
1536+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* ISO-8859-6 */
1537+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* ISO-8859-7 */
1538+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* ISO-8859-8 */
1539+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1250 */
1540+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1253 */
1541+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1254 */
1542+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1255 */
1543+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_WIN1257 */
1544+
{pg_latin12wchar_with_len,pg_wchar2single_with_len,pg_latin1_mblen,pg_latin1_dsplen,pg_latin1_verifier,1},/* PG_KOI8U */
1545+
{0,0,pg_sjis_mblen,pg_sjis_dsplen,pg_sjis_verifier,2},/* PG_SJIS */
1546+
{0,0,pg_big5_mblen,pg_big5_dsplen,pg_big5_verifier,2},/* PG_BIG5 */
1547+
{0,0,pg_gbk_mblen,pg_gbk_dsplen,pg_gbk_verifier,2},/* PG_GBK */
1548+
{0,0,pg_uhc_mblen,pg_uhc_dsplen,pg_uhc_verifier,2},/* PG_UHC */
1549+
{0,0,pg_gb18030_mblen,pg_gb18030_dsplen,pg_gb18030_verifier,4},/* PG_GB18030 */
1550+
{0,0,pg_johab_mblen,pg_johab_dsplen,pg_johab_verifier,3},/* PG_JOHAB */
1551+
{0,0,pg_sjis_mblen,pg_sjis_dsplen,pg_sjis_verifier,2}/* PG_SHIFT_JIS_2004 */
13861552
};
13871553

13881554
/* returns the byte length of a word for mule internal code */

‎src/include/mb/pg_wchar.h

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,27 @@ typedef unsigned int pg_wchar;
4949
/*
5050
* Is a prefix byte for "private" single byte encodings?
5151
*/
52-
#defineIS_LCPRV1(c)((unsigned char)(c) == 0x9a || (unsigned char)(c) == 0x9b)
52+
#defineLCPRV1_A0x9a
53+
#defineLCPRV1_B0x9b
54+
#defineIS_LCPRV1(c)((unsigned char)(c) == LCPRV1_A || (unsigned char)(c) == LCPRV1_B)
55+
#defineIS_LCPRV1_A_RANGE(c)\
56+
((unsigned char)(c) >= 0xa0 && (unsigned char)(c) <= 0xdf)
57+
#defineIS_LCPRV1_B_RANGE(c)\
58+
((unsigned char)(c) >= 0xe0 && (unsigned char)(c) <= 0xef)
5359
/*
5460
* Is a leading byte for "official" multibyte encodings?
5561
*/
5662
#defineIS_LC2(c)((unsigned char)(c) >= 0x90 && (unsigned char)(c) <= 0x99)
5763
/*
5864
* Is a prefix byte for "private" multibyte encodings?
5965
*/
60-
#defineIS_LCPRV2(c)((unsigned char)(c) == 0x9c || (unsigned char)(c) == 0x9d)
66+
#defineLCPRV2_A0x9c
67+
#defineLCPRV2_B0x9d
68+
#defineIS_LCPRV2(c)((unsigned char)(c) == LCPRV2_A || (unsigned char)(c) == LCPRV2_B)
69+
#defineIS_LCPRV2_A_RANGE(c)\
70+
((unsigned char)(c) >= 0xf0 && (unsigned char)(c) <= 0xf4)
71+
#defineIS_LCPRV2_B_RANGE(c)\
72+
((unsigned char)(c) >= 0xf5 && (unsigned char)(c) <= 0xfe)
6173

6274
/*----------------------------------------------------
6375
* leading characters
@@ -277,7 +289,11 @@ extern pg_enc2gettext pg_enc2gettext_tbl[];
277289
* pg_wchar stuff
278290
*/
279291
typedefint (*mb2wchar_with_len_converter) (constunsignedchar*from,
280-
pg_wchar*to,
292+
pg_wchar*to,
293+
intlen);
294+
295+
typedefint (*wchar2mb_with_len_converter) (constpg_wchar*from,
296+
unsignedchar*to,
281297
intlen);
282298

283299
typedefint (*mblen_converter) (constunsignedchar*mbstr);
@@ -288,8 +304,10 @@ typedef int (*mbverifier) (const unsigned char *mbstr, int len);
288304

289305
typedefstruct
290306
{
291-
mb2wchar_with_len_convertermb2wchar_with_len;/* convert a multibyte
292-
* string to a wchar */
307+
mb2wchar_with_len_convertermb2wchar_with_len;/* convert a multibyte
308+
* string to a wchar */
309+
wchar2mb_with_len_converterwchar2mb_with_len;/* convert a wchar
310+
* string to a multibyte */
293311
mblen_convertermblen;/* get byte length of a char */
294312
mbdisplaylen_converterdsplen;/* get display width of a char */
295313
mbverifiermbverify;/* verify multibyte sequence */
@@ -370,6 +388,10 @@ extern intpg_mb2wchar(const char *from, pg_wchar *to);
370388
externintpg_mb2wchar_with_len(constchar*from,pg_wchar*to,intlen);
371389
externintpg_encoding_mb2wchar_with_len(intencoding,
372390
constchar*from,pg_wchar*to,intlen);
391+
externintpg_wchar2mb(constpg_wchar*from,char*to);
392+
externintpg_wchar2mb_with_len(constpg_wchar*from,char*to,intlen);
393+
externintpg_encoding_wchar2mb_with_len(intencoding,
394+
constpg_wchar*from,char*to,intlen);
373395
externintpg_char_and_wchar_strcmp(constchar*s1,constpg_wchar*s2);
374396
externintpg_wchar_strncmp(constpg_wchar*s1,constpg_wchar*s2,size_tn);
375397
externintpg_char_and_wchar_strncmp(constchar*s1,constpg_wchar*s2,size_tn);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp