diff options
Diffstat (limited to 'src/backend/utils/mb/wchar.c')
| -rw-r--r-- | src/backend/utils/mb/wchar.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c index 114b7f2623..2da50bdd17 100644 --- a/src/backend/utils/mb/wchar.c +++ b/src/backend/utils/mb/wchar.c @@ -1,21 +1,21 @@ /* * conversion functions between pg_wchar and multi-byte streams. * Tatsuo Ishii - * $Id: wchar.c,v 1.20 2001/09/11 04:50:36 ishii Exp $ + * $Id: wchar.c,v 1.21 2001/09/21 15:27:38 tgl Exp $ * * WIN1250 client encoding updated by Pavel Behal * */ /* can be used in either frontend or backend */ -#include "postgres_fe.h" -#include "mb/pg_wchar.h" - #ifdef FRONTEND - #define Assert(condition) +#include "postgres_fe.h" +#define Assert(condition) #else - #include "postgres.h" +#include "postgres.h" #endif +#include "mb/pg_wchar.h" + /* * conversion to pg_wchar is done by "table driven." @@ -499,6 +499,17 @@ pg_encoding_mblen(int encoding, const unsigned char *mbstr) ((*pg_wchar_table[PG_SQL_ASCII].mblen) (mbstr))); } +/* + * fetch maximum length of a char encoding + */ +int +pg_encoding_max_length(int encoding) +{ + Assert(PG_VALID_ENCODING(encoding)); + + return pg_wchar_table[encoding].maxmblen; +} + #ifndef FRONTEND /* * Verify mbstr to make sure that it has a valid character sequence. @@ -517,7 +528,7 @@ pg_verifymbstr(const unsigned char *mbstr, int len) int slen = 0; /* we do not check single byte encodings */ - if (pg_wchar_table[GetDatabaseEncoding()].maxmblen <= 1) + if (pg_encoding_max_length(GetDatabaseEncoding()) <= 1) return NULL; while (len > 0 && *mbstr) |
