202 win32_get_codeset(
const char *ctype)
207 WCHAR wctype[LOCALE_NAME_MAX_LENGTH];
209 memset(wctype, 0,
sizeof(wctype));
210 MultiByteToWideChar(CP_ACP, 0, ctype, -1, wctype, LOCALE_NAME_MAX_LENGTH);
212 if (GetLocaleInfoEx(wctype,
213 LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
214 (LPWSTR) &cp,
sizeof(cp) /
sizeof(WCHAR)) > 0)
240 codepage = strrchr(ctype,
'.');
241 if (codepage != NULL)
246 ln = strlen(codepage);
250 if (strspn(codepage,
"0123456789") == ln)
267 pg_codepage_to_encoding(UINT cp)
280 (
errmsg(
"could not determine encoding for codeset \"%s\"", sys)));
322 loc = newlocale(LC_CTYPE_MASK, ctype, (
locale_t) 0);
326 sys = nl_langinfo_l(CODESET, loc);
332 sys = win32_get_codeset(ctype);
356 if (strlen(sys) == 0)
370 fprintf(stderr,
_(
"could not determine encoding for locale \"%s\": codeset is \"%s\""),
376 (
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