22 #ifdef HAVE_LANGINFO_H
202 win32_langinfo(
const char *ctype)
207 #if defined(_MSC_VER)
209 WCHAR wctype[LOCALE_NAME_MAX_LENGTH];
211 memset(wctype, 0,
sizeof(wctype));
212 MultiByteToWideChar(CP_ACP, 0, ctype, -1, wctype, LOCALE_NAME_MAX_LENGTH);
214 if (GetLocaleInfoEx(wctype,
215 LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
216 (LPWSTR) &cp,
sizeof(cp) /
sizeof(WCHAR)) > 0)
243 codepage = strrchr(ctype,
'.');
244 if (codepage != NULL)
249 ln = strlen(codepage);
253 if (strspn(codepage,
"0123456789") == ln)
270 pg_codepage_to_encoding(UINT cp)
283 (
errmsg(
"could not determine encoding for codeset \"%s\"", sys)));
290 #if (defined(HAVE_LANGINFO_H) && defined(CODESET)) || defined(WIN32)
338 sys = nl_langinfo(CODESET);
342 sys = win32_langinfo(
name);
361 sys = nl_langinfo(CODESET);
365 sys = win32_langinfo(ctype);
390 if (strlen(sys) == 0)
404 fprintf(stderr,
_(
"could not determine encoding for locale \"%s\": codeset is \"%s\""),
410 (
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