26 #ifdef LOCALE_T_IN_XLOCALE
206 win32_get_codeset(
const char *ctype)
211 WCHAR wctype[LOCALE_NAME_MAX_LENGTH];
213 memset(wctype, 0,
sizeof(wctype));
214 MultiByteToWideChar(CP_ACP, 0, ctype, -1, wctype, LOCALE_NAME_MAX_LENGTH);
216 if (GetLocaleInfoEx(wctype,
217 LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
218 (LPWSTR) &cp,
sizeof(cp) /
sizeof(WCHAR)) > 0)
244 codepage = strrchr(ctype,
'.');
245 if (codepage != NULL)
250 ln = strlen(codepage);
254 if (strspn(codepage,
"0123456789") == ln)
271 pg_codepage_to_encoding(UINT cp)
284 (
errmsg(
"could not determine encoding for codeset \"%s\"", sys)));
326 loc = newlocale(LC_CTYPE_MASK, ctype, (
locale_t) 0);
330 sys = nl_langinfo_l(CODESET, loc);
336 sys = win32_get_codeset(ctype);
360 if (strlen(sys) == 0)
374 fprintf(stderr,
_(
"could not determine encoding for locale \"%s\": codeset is \"%s\""),
380 (
errmsg(
"could not determine encoding for locale \"%s\": codeset is \"%s\"",
static const struct encoding_match encoding_match_list[]
int pg_get_encoding_from_locale(const char *ctype, bool write_message)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
int pg_strcasecmp(const char *s1, const char *s2)
const char * system_enc_name