*/
// Includes
+#include <locale.h>
#include <memory>
#include <stdlib.h>
#include <unistd.h>
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("");
}