Change the way to Convert UTF8 to wchar_t, and vice versa
[platform/framework/native/appfw.git] / src / base / FBase_StringConverter.cpp
index 05d8133..fc121c1 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
 * @brief               This is the implementation for _StringConverter class.
 */
 
-#include <stdlib.h>
 #include <new>
 #include <FBaseResult.h>
-#include "FBase_StringConverter.h"
 #include <FBaseSysLog.h>
-
-
+#include "FBase_StringConverter.h"
+#include "FBaseUtil_IcuConverter.h"
 
 namespace Tizen { namespace Base
 {
@@ -40,20 +37,7 @@ _StringConverter::CopyToCharArrayN(const String& str)
 char*
 _StringConverter::CopyToCharArrayN(const wchar_t* 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;
+       return Tizen::Base::Utility::WcharToUtf8N(pValue);
 }
 
 }} //Tizen::Base