diff options
| author | Tom Lane | 2011-04-23 16:35:41 +0000 |
|---|---|---|
| committer | Tom Lane | 2011-04-23 16:35:41 +0000 |
| commit | 2ab0796d7a3a7116a79b65531fd33f1548514b52 (patch) | |
| tree | b327fa2ba27bef4dbd2dd287e23b5bf6ba8ac2ee /src/include/mb | |
| parent | bb850306307d3d6ebb611c4039ae127236eb1699 (diff) | |
Fix char2wchar/wchar2char to support collations properly.
These functions should take a pg_locale_t, not a collation OID, and should
call mbstowcs_l/wcstombs_l where available. Where those functions are not
available, temporarily select the correct locale with uselocale().
This change removes the bogus assumption that all locales selectable in
a given database have the same wide-character conversion method; in
particular, the collate.linux.utf8 regression test now passes with
LC_CTYPE=C, so long as the database encoding is UTF8.
I decided to move the char2wchar/wchar2char functions out of mbutils.c and
into pg_locale.c, because they work on wchar_t not pg_wchar_t and thus
don't really belong with the mbutils.c functions. Keeping them where they
were would have required importing pg_locale_t into pg_wchar.h somehow,
which did not seem like a good plan.
Diffstat (limited to 'src/include/mb')
| -rw-r--r-- | src/include/mb/pg_wchar.h | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h index 8efc6d3046..826c7af53b 100644 --- a/src/include/mb/pg_wchar.h +++ b/src/include/mb/pg_wchar.h @@ -19,8 +19,6 @@ #ifndef PG_WCHAR_H #define PG_WCHAR_H -#include <sys/types.h> - /* * The pg_wchar type */ @@ -392,11 +390,6 @@ extern int pg_mbcharcliplen(const char *mbstr, int len, int imit); extern int pg_encoding_max_length(int encoding); extern int pg_database_encoding_max_length(void); -#ifdef USE_WIDE_UPPER_LOWER -extern size_t wchar2char(char *to, const wchar_t *from, size_t tolen, Oid collation); -extern size_t char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen, Oid collation); -#endif - extern int PrepareClientEncoding(int encoding); extern int SetClientEncoding(int encoding); extern void InitializeClientEncoding(void); |
