Enable helpbrowser within YaSp
[scilab.git] / scilab / modules / localization / src / c / getLocaleInfo_Windows.c
index b78d35c..175e570 100644 (file)
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include "getLocaleInfo_Windows.h"
 #include "MALLOC.h"
+#include "os_swprintf.h"
 /*--------------------------------------------------------------------------*/
 char* getLocaleSystemInfo(void)
 {
@@ -61,42 +62,41 @@ wchar_t* getLocaleUserInfo(void)
        wchar_t buffer_LOCALE_IDEFAULTANSICODEPAGE[LENGTH_BUFFER]; 
        wchar_t *localeStr = NULL;
        int ret = 0;
-       ret = GetLocaleInfo(LOCALE_USER_DEFAULT,
+       ret = GetLocaleInfoW(LOCALE_USER_DEFAULT,
                                                LOCALE_SISO639LANGNAME,
-                                               &buffer_LOCALE_SISO639LANGNAME[0],
+                                               buffer_LOCALE_SISO639LANGNAME,
                                                LENGTH_BUFFER);
        if (ret > 0)
        {
 
-               ret = GetLocaleInfo(LOCALE_USER_DEFAULT,
+               ret = GetLocaleInfoW(LOCALE_USER_DEFAULT,
                                                        LOCALE_SISO3166CTRYNAME,
-                                                       &buffer_LOCALE_SISO3166CTRYNAME[0],
+                                                       buffer_LOCALE_SISO3166CTRYNAME,
                                                        LENGTH_BUFFER);
                if (ret >0)
                {
             // BY YJLee get Windows CODE Page Information
-                       int ret = GetLocaleInfo(LOCALE_USER_DEFAULT,
+                       int ret = GetLocaleInfoW(LOCALE_USER_DEFAULT,
                                                LOCALE_IDEFAULTANSICODEPAGE,
-                                               &buffer_LOCALE_IDEFAULTANSICODEPAGE[0],
+                                               buffer_LOCALE_IDEFAULTANSICODEPAGE,
                                                LENGTH_BUFFER);
 
-                       int length_localeStr = (int)(strlen(buffer_LOCALE_SISO639LANGNAME)+
-                                                                                strlen(buffer_LOCALE_SISO3166CTRYNAME)+
-                                                                                strlen(buffer_LOCALE_IDEFAULTANSICODEPAGE)+
-                                                                                strlen("_.CP") );
-                       localeStr = (char*)MALLOC(sizeof(char)*(length_localeStr)+1);
+                       int length_localeStr = (int)(wcslen(buffer_LOCALE_SISO639LANGNAME)+
+                                                                                wcslen(buffer_LOCALE_SISO3166CTRYNAME)+
+                                                                                wcslen(buffer_LOCALE_IDEFAULTANSICODEPAGE)+
+                                                                                wcslen(L"_.CP") );
+                       localeStr = (wchar_t*)MALLOC(sizeof(wchar_t) * (length_localeStr + 1));
                        if (localeStr)
                        {
                                #ifdef FORMAT_LOCALE
                                        #undef FORMAT_LOCALE
                                #endif
-                               #define FORMAT_LOCALE "%s_%s.CP%s"
+                               #define FORMAT_LOCALE L"%s_%s.CP%s"
                                // in lang_contry.CPxxx format
-                               sprintf(localeStr,FORMAT_LOCALE,
+                os_swprintf(localeStr, length_localeStr + 1, FORMAT_LOCALE,
                                                      buffer_LOCALE_SISO639LANGNAME,
                                                                  buffer_LOCALE_SISO3166CTRYNAME,
-                                                                 buffer_LOCALE_IDEFAULTANSICODEPAGE
-                                                                 );
+                                                                 buffer_LOCALE_IDEFAULTANSICODEPAGE);
                        }
                }
        }