Change the way to Convert UTF8 to wchar_t, and vice versa
[platform/framework/native/appfw.git] / src / base / inc / FBaseUtil_IcuConverter.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                FBaseUtil_IcuConverter.h
19  * @brief               This is the header file for _ICUConverter.
20  */
21
22 #ifndef _FBASE_UTIL_ICU_CONVERTER_H_
23 #define _FBASE_UTIL_ICU_CONVERTER_H_
24
25 #include "unicode/ucnv.h"
26 #include "unicode/utypes.h"
27 #include <FBaseUtilTypes.h>
28 #include <FBaseString.h>
29
30
31 namespace Tizen { namespace Base { namespace Utility
32 {
33
34 class _ICUConverter
35 {
36 public:
37         _ICUConverter();
38         ~_ICUConverter();
39         bool OpenConverter(const Tizen::Base::String& encodingScheme);
40         wchar_t* ConvertToUcharN(const char* src, int srcLength);
41         char* ConvertFromUcharN(const wchar_t* pSrc, int srcLength, int& retLength);
42         void CloseConverter(void);
43
44 private:
45         result GetResultFromIcuErrorCode(UErrorCode& err);
46         UConverter* __pConverter;
47 }; // _ICUConverter
48
49 char* WcharToUtf8N(const wchar_t* pValue);
50 wchar_t* Utf8ToWcharN(const char* pValue);
51
52 }}} // Tizen::Base::Utility
53
54 #endif // _FBASE_UTIL_ICU_CONVERTER_H_