apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r543313 - /apr/apr/trunk/misc/win32/charset.c
Date Thu, 31 May 2007 23:45:52 GMT
Author: wrowe
Date: Thu May 31 16:45:51 2007
New Revision: 543313

URL: http://svn.apache.org/viewvc?view=rev&rev=543313
Log:
WinCE exception to deal with local code page (in unicode, no less)

PR: 39852
Submitted by: Curt Arnold <carnold apache.org>

Modified:
    apr/apr/trunk/misc/win32/charset.c

Modified: apr/apr/trunk/misc/win32/charset.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/misc/win32/charset.c?view=diff&rev=543313&r1=543312&r2=543313
==============================================================================
--- apr/apr/trunk/misc/win32/charset.c (original)
+++ apr/apr/trunk/misc/win32/charset.c Thu May 31 16:45:51 2007
@@ -27,15 +27,27 @@
 
 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;
     }
 



Mime
View raw message