summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2007-05-31 23:47:01 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2007-05-31 23:47:01 +0000
commit7a5b26131d213de1382c9a01813f0f0f74181115 (patch)
tree2dff9574907ebb0c5764ddd327d9367be0f0cb30
parentcd724194584beac8b91c28194558d8c4aa65e5e5 (diff)
downloadlibapr-7a5b26131d213de1382c9a01813f0f0f74181115.tar.gz
WinCE exception to deal with local code page (in unicode, no less)
PR: 39852 Submitted by: Curt Arnold <carnold apache.org> Backport: 543313 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/0.9.x@543315 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--misc/win32/charset.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/misc/win32/charset.c b/misc/win32/charset.c
index d54d6e645..41135b25d 100644
--- a/misc/win32/charset.c
+++ b/misc/win32/charset.c
@@ -27,15 +27,27 @@ APR_DECLARE(const char*) apr_os_default_encoding (apr_pool_t *pool)
APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool)
{
+#ifdef _UNICODE
+ int i;
+#endif
+#if defined(_WIN32_WCE)
+ LCID locale = GetUserDefaultLCID();
+#else
LCID locale = GetThreadLocale();
+#endif
int len = GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, NULL, 0);
- char *cp = apr_palloc(pool, len + 2);
- if (0 < GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, cp + 2, len))
+ char *cp = apr_palloc(pool, (len * sizeof(TCHAR)) + 2);
+ if (0 < GetLocaleInfo(locale, LOCALE_IDEFAULTANSICODEPAGE, (TCHAR*) (cp + 2), len))
{
/* Fix up the returned number to make a valid codepage name of
the form "CPnnnn". */
cp[0] = 'C';
cp[1] = 'P';
+#ifdef _UNICODE
+ for(i = 0; i < len; i++) {
+ cp[i + 2] = (char) ((TCHAR*) (cp + 2))[i];
+ }
+#endif
return cp;
}