Revert "Change the way to conver Mbs to Wcs and vice versa"
[platform/framework/native/appfw.git] / src / base / FBase_StringConverter.cpp
index be93bb2..05d8133 100644 (file)
 * @brief               This is the implementation for _StringConverter class.
 */
 
+#include <stdlib.h>
 #include <new>
 #include <FBaseResult.h>
-#include <FBaseSysLog.h>
 #include "FBase_StringConverter.h"
-#include "FBaseUtil_IcuConverter.h"
+#include <FBaseSysLog.h>
+
+
 
 namespace Tizen { namespace Base
 {
@@ -38,7 +40,20 @@ _StringConverter::CopyToCharArrayN(const String& str)
 char*
 _StringConverter::CopyToCharArrayN(const wchar_t* pValue)
 {
-       return Tizen::Base::Utility::ConvertWcsToMbsN(pValue);
+       char* pRet = null;
+
+       int len = wcstombs(0, pValue, 0);
+       SysTryReturn(NID_BASE, len != -1, null, E_INVALID_ARG, "[%s] Invalid argument is used. Invalid string.",
+               GetErrorMessage(E_INVALID_ARG));
+
+       pRet = new (std::nothrow) char[len + 1];
+       SysTryReturn(NID_BASE, pRet != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
+               GetErrorMessage(E_OUT_OF_MEMORY));
+
+       len = wcstombs(pRet, pValue, len);
+       pRet[len] = 0;
+
+       return pRet;
 }
 
 }} //Tizen::Base