strFree (anOldBuffer);
}
+#if !defined(__ANDROID__)
//! Auxiliary convertion tool.
class NCollection_UtfStringTool
{
private:
wchar_t* myWideBuffer; //!< temporary variable
};
+#endif
// =======================================================================
// function : FromLocale
void NCollection_UtfString<Type>::FromLocale (const char* theString,
const Standard_Integer theLength)
{
+#if defined(__ANDROID__)
+ // no locales on Android
+ FromUnicode (theString, theLength);
+#else
NCollection_UtfStringTool aConvertor;
wchar_t* aWideBuffer = aConvertor.FromLocale (theString);
if (aWideBuffer == NULL)
return;
}
FromUnicode (aWideBuffer, theLength);
+#endif
}
// =======================================================================
bool NCollection_UtfString<Type>::ToLocale (char* theBuffer,
const Standard_Integer theSizeBytes) const
{
+#if defined(__ANDROID__)
+ // no locales on Android
+ NCollection_UtfString<Standard_Utf8Char> anUtf8Copy (myString, myLength);
+ const Standard_Integer aSize = anUtf8Copy.Size() + 1;
+ if (theSizeBytes < aSize)
+ {
+ return false;
+ }
+ std::memcpy (theBuffer, anUtf8Copy.ToCString(), (Standard_Size )aSize);
+ return true;
+#else
NCollection_UtfString<wchar_t> aWideCopy (myString, myLength);
return NCollection_UtfStringTool::ToLocale (aWideCopy.ToCString(), theBuffer, theSizeBytes);
+#endif
}
// =======================================================================