Update converting UnicodeStriong to OspSting
authorHokwon Song <hokwon.song@samsung.com>
Thu, 11 Apr 2013 04:49:34 +0000 (13:49 +0900)
committerHokwon Song <hokwon.song@samsung.com>
Thu, 11 Apr 2013 04:54:23 +0000 (13:54 +0900)
Change-Id: I84d8a6d9f52b59266dfa2bc49338caddd25def03
Signed-off-by: Hokwon Song <hokwon.song@samsung.com>
src/locales/FLcl_LocaleData.cpp

index 91f1861..1b129e1 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 // Includes
+#include <locale.h>
 #include <memory>
 #include <stdlib.h>
 #include <unistd.h>
@@ -82,17 +83,24 @@ _LocaleData::GetIcuString(const String& ospStr)
 
       return icuStr;
 }
+
 // This function convert ICU string to OSP string
 String
 _LocaleData::GetOspString(const IcuUnicodeString& icuStr)
 {
        int len = icuStr.length();                                  // get length
-       if (len)                                                    // if icuStr is not empty
+       if (len > 0)                                                    // if icuStr is not empty
        {
-               char out[len * 3 + 1];                                  // Create buffer of thrice the icuStr length
-               int end = icuStr.extract(0, len, out);
-               out[end] = 0;                   // icuStr.extract() converts Unicode to UTF8
-               return String(out);
+               wchar_t wstr[len + 1];
+               IcuUnicodeString tmpIcuStr(icuStr);
+               for (int i = 0; i < len ; i++)
+               {
+                       UChar icuChar;
+                       icuChar = tmpIcuStr.charAt(i);
+                       wstr[i] = (wchar_t)icuChar;
+               }
+               wstr[len] = 0;
+               return String(wstr);
        }
        return String("");
 }