Skip to content

Commit 72dd629

Browse files
committed
Add wchar -> mb conversion routines.
This is infrastructure for Alexander Korotkov's work on indexing regular expression searches. Alexander Korotkov, with a bit of further hackery on the MULE conversion by me
1 parent 248b5fc commit 72dd629

File tree

3 files changed

+248
-45
lines changed

3 files changed

+248
-45
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) ((const unsigned char *) from, to, len);
711711
}
712712

713+
/* convert a wchar string to a multibyte */
714+
int
715+
pg_wchar2mb(const pg_wchar *from, char *to)
716+
{
717+
return (*pg_wchar_table[DatabaseEncoding->encoding].wchar2mb_with_len) (from, (unsigned char *)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(const pg_wchar *from, char *to, int len)
723+
{
724+
return (*pg_wchar_table[DatabaseEncoding->encoding].wchar2mb_with_len) (from, (unsigned char *)to, len);
725+
}
726+
727+
/* same, with any encoding */
728+
int
729+
pg_encoding_wchar2mb_with_len(int encoding,
730+
const pg_wchar *from, char *to, int len)
731+
{
732+
return (*pg_wchar_table[encoding].wchar2mb_with_len) (from, (unsigned char *)to, len);
733+
}
734+
713735
/* returns the byte length of a multibyte character */
714736
int
715737
pg_mblen(const char *mbstr)

src/backend/utils/mb/wchar.c

Lines changed: 205 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,54 @@ pg_euctw_dsplen(const unsigned char *s)
339339
return len;
340340
}
341341

342+
/*
343+
* Convert pg_wchar to EUC_* encoding.
344+
* caller must allocate enough space for "to", including a trailing zero!
345+
* len: length of from.
346+
* "from" not necessarily null terminated.
347+
*/
348+
static int
349+
pg_wchar2euc_with_len(const pg_wchar *from, unsigned char *to, int len)
350+
{
351+
int cnt = 0;
352+
353+
while (len > 0 && *from)
354+
{
355+
unsigned char c;
356+
357+
if ((c = *from >> 24))
358+
{
359+
*to++ = c;
360+
*to++ = (*from >> 16) & 0xff;
361+
*to++ = (*from >> 8) & 0xff;
362+
*to++ = *from & 0xff;
363+
cnt += 4;
364+
}
365+
else if ((c = *from >> 16))
366+
{
367+
*to++ = c;
368+
*to++ = (*from >> 8) & 0xff;
369+
*to++ = *from & 0xff;
370+
cnt += 3;
371+
}
372+
else if ((c = *from >> 8))
373+
{
374+
*to++ = c;
375+
*to++ = *from & 0xff;
376+
cnt += 2;
377+
}
378+
else
379+
{
380+
*to++ = *from;
381+
cnt++;
382+
}
383+
len--;
384+
}
385+
*to = 0;
386+
return cnt;
387+
}
388+
389+
342390
/*
343391
* JOHAB
344392
*/
@@ -453,6 +501,30 @@ unicode_to_utf8(pg_wchar c, unsigned char *utf8string)
453501
return utf8string;
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+
static int
511+
pg_wchar2utf_with_len(const pg_wchar *from, unsigned char *to, int len)
512+
{
513+
int cnt = 0;
514+
515+
while (len > 0 && *from)
516+
{
517+
int char_len;
518+
519+
unicode_to_utf8(*from, to);
520+
char_len = pg_utf_mblen(to);
521+
len--;
522+
cnt += char_len;
523+
to += char_len;
524+
}
525+
*to = 0;
526+
return cnt;
527+
}
456528

457529
/*
458530
* Return the byte length of a UTF8 character pointed to by s
@@ -719,6 +791,75 @@ pg_mule2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
719791
return cnt;
720792
}
721793

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

924+
/*
925+
* Trivial conversion from pg_wchar to single byte encoding. Just ignores
926+
* high bits.
927+
* caller should allocate enough space for "to"
928+
* len: length of from.
929+
* "from" not necessarily null terminated.
930+
*/
931+
static int
932+
pg_wchar2single_with_len(const pg_wchar *from, unsigned char *to, int len)
933+
{
934+
int cnt = 0;
935+
936+
while (len > 0 && *from)
937+
{
938+
*to++ = *from++;
939+
len--;
940+
cnt++;
941+
}
942+
*to = 0;
943+
return cnt;
944+
}
945+
783946
static int
784947
pg_latin1_mblen(const unsigned char *s)
785948
{
@@ -1556,48 +1719,48 @@ pg_eucjp_increment(unsigned char *charptr, int length)
15561719
*-------------------------------------------------------------------
15571720
*/
15581721
pg_wchar_tbl pg_wchar_table[] = {
1559-
{pg_ascii2wchar_with_len, pg_ascii_mblen, pg_ascii_dsplen, pg_ascii_verifier, 1}, /* PG_SQL_ASCII */
1560-
{pg_eucjp2wchar_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, pg_eucjp_verifier, 3}, /* PG_EUC_JP */
1561-
{pg_euccn2wchar_with_len, pg_euccn_mblen, pg_euccn_dsplen, pg_euccn_verifier, 2}, /* PG_EUC_CN */
1562-
{pg_euckr2wchar_with_len, pg_euckr_mblen, pg_euckr_dsplen, pg_euckr_verifier, 3}, /* PG_EUC_KR */
1563-
{pg_euctw2wchar_with_len, pg_euctw_mblen, pg_euctw_dsplen, pg_euctw_verifier, 4}, /* PG_EUC_TW */
1564-
{pg_eucjp2wchar_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, pg_eucjp_verifier, 3}, /* PG_EUC_JIS_2004 */
1565-
{pg_utf2wchar_with_len, pg_utf_mblen, pg_utf_dsplen, pg_utf8_verifier, 4}, /* PG_UTF8 */
1566-
{pg_mule2wchar_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
1567-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
1568-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
1569-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
1570-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
1571-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
1572-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
1573-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
1574-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
1575-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
1576-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
1577-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1256 */
1578-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1258 */
1579-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN866 */
1580-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN874 */
1581-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_KOI8R */
1582-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1251 */
1583-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1252 */
1584-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* ISO-8859-5 */
1585-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* ISO-8859-6 */
1586-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* ISO-8859-7 */
1587-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* ISO-8859-8 */
1588-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1250 */
1589-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1253 */
1590-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1254 */
1591-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1255 */
1592-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1257 */
1593-
{pg_latin12wchar_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_KOI8U */
1594-
{0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2}, /* PG_SJIS */
1595-
{0, pg_big5_mblen, pg_big5_dsplen, pg_big5_verifier, 2}, /* PG_BIG5 */
1596-
{0, pg_gbk_mblen, pg_gbk_dsplen, pg_gbk_verifier, 2}, /* PG_GBK */
1597-
{0, pg_uhc_mblen, pg_uhc_dsplen, pg_uhc_verifier, 2}, /* PG_UHC */
1598-
{0, pg_gb18030_mblen, pg_gb18030_dsplen, pg_gb18030_verifier, 4}, /* PG_GB18030 */
1599-
{0, pg_johab_mblen, pg_johab_dsplen, pg_johab_verifier, 3}, /* PG_JOHAB */
1600-
{0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2} /* PG_SHIFT_JIS_2004 */
1722+
{pg_ascii2wchar_with_len, pg_wchar2single_with_len, pg_ascii_mblen, pg_ascii_dsplen, pg_ascii_verifier, 1}, /* PG_SQL_ASCII */
1723+
{pg_eucjp2wchar_with_len, pg_wchar2euc_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, pg_eucjp_verifier, 3}, /* PG_EUC_JP */
1724+
{pg_euccn2wchar_with_len, pg_wchar2euc_with_len, pg_euccn_mblen, pg_euccn_dsplen, pg_euccn_verifier, 2}, /* PG_EUC_CN */
1725+
{pg_euckr2wchar_with_len, pg_wchar2euc_with_len, pg_euckr_mblen, pg_euckr_dsplen, pg_euckr_verifier, 3}, /* PG_EUC_KR */
1726+
{pg_euctw2wchar_with_len, pg_wchar2euc_with_len, pg_euctw_mblen, pg_euctw_dsplen, pg_euctw_verifier, 4}, /* PG_EUC_TW */
1727+
{pg_eucjp2wchar_with_len, pg_wchar2euc_with_len, pg_eucjp_mblen, pg_eucjp_dsplen, pg_eucjp_verifier, 3}, /* PG_EUC_JIS_2004 */
1728+
{pg_utf2wchar_with_len, pg_wchar2utf_with_len, pg_utf_mblen, pg_utf_dsplen, pg_utf8_verifier, 4}, /* PG_UTF8 */
1729+
{pg_mule2wchar_with_len, pg_wchar2mule_with_len, pg_mule_mblen, pg_mule_dsplen, pg_mule_verifier, 4}, /* PG_MULE_INTERNAL */
1730+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN1 */
1731+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN2 */
1732+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN3 */
1733+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN4 */
1734+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN5 */
1735+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN6 */
1736+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN7 */
1737+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN8 */
1738+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN9 */
1739+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_LATIN10 */
1740+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1256 */
1741+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1258 */
1742+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN866 */
1743+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN874 */
1744+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_KOI8R */
1745+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1251 */
1746+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1252 */
1747+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* ISO-8859-5 */
1748+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* ISO-8859-6 */
1749+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* ISO-8859-7 */
1750+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* ISO-8859-8 */
1751+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1250 */
1752+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1253 */
1753+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1254 */
1754+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1255 */
1755+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_WIN1257 */
1756+
{pg_latin12wchar_with_len, pg_wchar2single_with_len, pg_latin1_mblen, pg_latin1_dsplen, pg_latin1_verifier, 1}, /* PG_KOI8U */
1757+
{0, 0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2}, /* PG_SJIS */
1758+
{0, 0, pg_big5_mblen, pg_big5_dsplen, pg_big5_verifier, 2}, /* PG_BIG5 */
1759+
{0, 0, pg_gbk_mblen, pg_gbk_dsplen, pg_gbk_verifier, 2}, /* PG_GBK */
1760+
{0, 0, pg_uhc_mblen, pg_uhc_dsplen, pg_uhc_verifier, 2}, /* PG_UHC */
1761+
{0, 0, pg_gb18030_mblen, pg_gb18030_dsplen, pg_gb18030_verifier, 4}, /* PG_GB18030 */
1762+
{0, 0, pg_johab_mblen, pg_johab_dsplen, pg_johab_verifier, 3}, /* PG_JOHAB */
1763+
{0, 0, pg_sjis_mblen, pg_sjis_dsplen, pg_sjis_verifier, 2} /* PG_SHIFT_JIS_2004 */
16011764
};
16021765

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

src/include/mb/pg_wchar.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ typedef unsigned int pg_wchar;
140140
#define LCPRV1_A 0x9a
141141
#define LCPRV1_B 0x9b
142142
#define IS_LCPRV1(c) ((unsigned char)(c) == LCPRV1_A || (unsigned char)(c) == LCPRV1_B)
143+
#define IS_LCPRV1_A_RANGE(c) \
144+
((unsigned char)(c) >= 0xa0 && (unsigned char)(c) <= 0xdf)
145+
#define IS_LCPRV1_B_RANGE(c) \
146+
((unsigned char)(c) >= 0xe0 && (unsigned char)(c) <= 0xef)
143147

144148
/*
145149
* Postgres-specific prefix bytes for "private" multibyte encodings
@@ -148,6 +152,10 @@ typedef unsigned int pg_wchar;
148152
#define LCPRV2_A 0x9c
149153
#define LCPRV2_B 0x9d
150154
#define IS_LCPRV2(c) ((unsigned char)(c) == LCPRV2_A || (unsigned char)(c) == LCPRV2_B)
155+
#define IS_LCPRV2_A_RANGE(c) \
156+
((unsigned char)(c) >= 0xf0 && (unsigned char)(c) <= 0xf4)
157+
#define IS_LCPRV2_B_RANGE(c) \
158+
((unsigned char)(c) >= 0xf5 && (unsigned char)(c) <= 0xfe)
151159

152160
/*
153161
* Charset IDs for private single byte encodings (0xa0-0xef)
@@ -324,7 +332,11 @@ extern pg_enc2gettext pg_enc2gettext_tbl[];
324332
* pg_wchar stuff
325333
*/
326334
typedef int (*mb2wchar_with_len_converter) (const unsigned char *from,
327-
pg_wchar *to,
335+
pg_wchar *to,
336+
int len);
337+
338+
typedef int (*wchar2mb_with_len_converter) (const pg_wchar *from,
339+
unsigned char *to,
328340
int len);
329341

330342
typedef int (*mblen_converter) (const unsigned char *mbstr);
@@ -337,8 +349,10 @@ typedef int (*mbverifier) (const unsigned char *mbstr, int len);
337349

338350
typedef struct
339351
{
340-
mb2wchar_with_len_converter mb2wchar_with_len; /* convert a multibyte
341-
* string to a wchar */
352+
mb2wchar_with_len_converter mb2wchar_with_len; /* convert a multibyte
353+
* string to a wchar */
354+
wchar2mb_with_len_converter wchar2mb_with_len; /* convert a wchar
355+
* string to a multibyte */
342356
mblen_converter mblen; /* get byte length of a char */
343357
mbdisplaylen_converter dsplen; /* get display width of a char */
344358
mbverifier mbverify; /* verify multibyte sequence */
@@ -419,6 +433,10 @@ extern int pg_mb2wchar(const char *from, pg_wchar *to);
419433
extern int pg_mb2wchar_with_len(const char *from, pg_wchar *to, int len);
420434
extern int pg_encoding_mb2wchar_with_len(int encoding,
421435
const char *from, pg_wchar *to, int len);
436+
extern int pg_wchar2mb(const pg_wchar *from, char *to);
437+
extern int pg_wchar2mb_with_len(const pg_wchar *from, char *to, int len);
438+
extern int pg_encoding_wchar2mb_with_len(int encoding,
439+
const pg_wchar *from, char *to, int len);
422440
extern int pg_char_and_wchar_strcmp(const char *s1, const pg_wchar *s2);
423441
extern int pg_wchar_strncmp(const pg_wchar *s1, const pg_wchar *s2, size_t n);
424442
extern int pg_char_and_wchar_strncmp(const char *s1, const pg_wchar *s2, size_t n);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy