diff --git a/src/port/chklocale.c b/src/port/chklocale.c
index a551fdc..11177f6 100644
--- a/src/port/chklocale.c
+++ b/src/port/chklocale.c
@@ -203,7 +203,7 @@ win32_langinfo(const char *ctype)
 {
 	char	   *r = NULL;
 
-#if (_MSC_VER >= 1700)
+#if (_MSC_VER >= 1700) && (_MSC_VER < 1900)
 	_locale_t	loct = NULL;
 
 	loct = _create_locale(LC_CTYPE, ctype);
@@ -215,8 +215,23 @@ win32_langinfo(const char *ctype)
 		_free_locale(loct);
 	}
 #else
+
 	char	   *codepage;
 
+#if (_MSC_VER >= 1900)
+	uint32	cp;
+
+	if (GetLocaleInfoEx(ctype, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, (LPWSTR)&cp, sizeof(cp)/sizoef(WCHAR)) > 0)
+	{
+		r = malloc(16);			/* excess */
+		if (r != NULL)
+			sprintf(r, "CP%u", cp);
+	}
+	else
+	{
+#endif
+
+
 	/*
 	 * Locale format on Win32 is <Language>_<Country>.<CodePage> . For
 	 * example, English_United States.1252.
@@ -232,6 +247,10 @@ win32_langinfo(const char *ctype)
 		if (r != NULL)
 			sprintf(r, "CP%s", codepage);
 	}
+
+#if (_MSC_VER >= 1900)
+	}
+#endif
 #endif
 
 	return r;
