22 #ifdef HAVE_LANGINFO_H 211 win32_langinfo(
const char *ctype)
215 #if defined(_MSC_VER) && (_MSC_VER < 1900) 216 _locale_t loct = NULL;
218 loct = _create_locale(LC_CTYPE, ctype);
223 sprintf(r,
"CP%u", loct->locinfo->lc_codepage);
229 #if defined(_MSC_VER) && (_MSC_VER >= 1900) 231 WCHAR wctype[LOCALE_NAME_MAX_LENGTH];
233 memset(wctype, 0,
sizeof(wctype));
234 MultiByteToWideChar(CP_ACP, 0, ctype, -1, wctype, LOCALE_NAME_MAX_LENGTH);
236 if (GetLocaleInfoEx(wctype,
237 LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
238 (LPWSTR) &cp,
sizeof(cp) /
sizeof(WCHAR)) > 0)
265 codepage = strrchr(ctype,
'.');
266 if (codepage != NULL)
271 ln = strlen(codepage);
275 if (strspn(codepage,
"0123456789") == ln)
294 pg_codepage_to_encoding(UINT cp)
307 (
errmsg(
"could not determine encoding for codeset \"%s\"", sys)));
314 #if (defined(HAVE_LANGINFO_H) && defined(CODESET)) || defined(WIN32) 362 sys = nl_langinfo(CODESET);
366 sys = win32_langinfo(name);
385 sys = nl_langinfo(CODESET);
389 sys = win32_langinfo(ctype);
414 if (strlen(sys) == 0)
428 fprintf(stderr,
_(
"could not determine encoding for locale \"%s\": codeset is \"%s\""),
434 (
errmsg(
"could not determine encoding for locale \"%s\": codeset is \"%s\"",
int pg_strcasecmp(const char *s1, const char *s2)
const char * system_enc_name
static const struct encoding_match encoding_match_list[]
#define ereport(elevel,...)
int pg_get_encoding_from_locale(const char *ctype, bool write_message)
int errmsg(const char *fmt,...)