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)
293 pg_codepage_to_encoding(UINT cp)
306 (
errmsg(
"could not determine encoding for codeset \"%s\"", sys)));
313 #if (defined(HAVE_LANGINFO_H) && defined(CODESET)) || defined(WIN32)
361 sys = nl_langinfo(CODESET);
365 sys = win32_langinfo(
name);
384 sys = nl_langinfo(CODESET);
388 sys = win32_langinfo(ctype);
413 if (strlen(sys) == 0)
427 fprintf(stderr,
_(
"could not determine encoding for locale \"%s\": codeset is \"%s\""),
433 (
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