From 7a5b26131d213de1382c9a01813f0f0f74181115 Mon Sep 17 00:00:00 2001 From: wrowe Date: Thu, 31 May 2007 23:47:01 +0000 Subject: WinCE exception to deal with local code page (in unicode, no less) PR: 39852 Submitted by: Curt Arnold Backport: 543313 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/0.9.x@543315 13f79535-47bb-0310-9956-ffa450edef68 --- misc/win32/charset.c | 16 ++++++++++++++-- 1 file 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; } -- cgit v1.2.1