2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FTextUtf8Encoding.cpp
20 * @brief This is the implementation file for UTF-8 Encoding class.
23 #include <FTextUtf8Encoding.h>
24 #include <FBaseSysLog.h>
25 #include "FText_EncodingImpl.h"
28 #define ENCODING_NAME L"UTF-8"
30 using namespace Tizen::Base;
32 namespace Tizen { namespace Text
36 Utf8Encoding::Utf8Encoding(void)
37 : __pUtf8EncodingImpl(null)
39 _pEncodingImpl = new (std::nothrow) _EncodingImpl;
42 result r = _pEncodingImpl->Construct(ENCODING_NAME);
45 delete _pEncodingImpl;
46 _pEncodingImpl = null;
50 SysAssert(_pEncodingImpl);
54 Utf8Encoding::~Utf8Encoding(void)
56 delete _pEncodingImpl;
61 Utf8Encoding::GetByteCount(const String& str, int& byteCount) const
63 return _pEncodingImpl->GetByteCount(str, byteCount);
68 Utf8Encoding::GetByteCount(const WcharBuffer& chars, int& byteCount) const
70 return _pEncodingImpl->GetByteCount(chars, byteCount);
75 Utf8Encoding::GetByteCount(const WcharBuffer& chars, int charIndex, int charCount, int& byteCount) const
77 return _pEncodingImpl->GetByteCount(chars, charIndex, charCount, byteCount);
82 Utf8Encoding::GetBytesN(const WcharBuffer& chars) const
84 return _pEncodingImpl->GetBytesN(chars);
89 Utf8Encoding::GetBytesN(const String& str) const
91 return _pEncodingImpl->GetBytesN(str);
96 Utf8Encoding::GetBytes(const WcharBuffer& chars, int charIndex, int charCount, ByteBuffer& bytes, int byteIndex) const
98 return _pEncodingImpl->GetBytes(chars, charIndex, charCount, bytes, byteIndex);
103 Utf8Encoding::GetBytes(const String& str, int charIndex, int charCount, ByteBuffer& bytes, int byteIndex) const
105 return _pEncodingImpl->GetBytes(str, charIndex, charCount, bytes, byteIndex);
110 Utf8Encoding::GetCharCount(const ByteBuffer& bytes, int& charCount) const
112 return _pEncodingImpl->GetCharCount(bytes, charCount);
117 Utf8Encoding::GetCharCount(const ByteBuffer& bytes, int byteIndex, int byteCount, int& charCount) const
119 return _pEncodingImpl->GetCharCount(bytes, byteIndex, byteCount, charCount);
124 Utf8Encoding::GetCharsN(const ByteBuffer& bytes) const
126 return _pEncodingImpl->GetCharsN(bytes);
131 Utf8Encoding::GetChars(const ByteBuffer& bytes, int byteIndex, int byteCount, WcharBuffer& chars, int charIndex) const
133 return _pEncodingImpl->GetChars(bytes, byteIndex, byteCount, chars, charIndex);
138 Utf8Encoding::GetString(const ByteBuffer& bytes, String& str) const
140 return _pEncodingImpl->GetString(bytes, str);
145 Utf8Encoding::GetString(const ByteBuffer& bytes, int byteIndex, int byteCount, String& str) const
147 return _pEncodingImpl->GetString(bytes, byteIndex, byteCount, str);
152 Utf8Encoding::GetMaxByteCount(int charCount) const
154 return charCount * 3;
159 Utf8Encoding::GetMaxCharCount(int byteCount) const
166 Utf8Encoding::GetEncoderN(void) const
168 return new (std::nothrow) Utf8Encoder();
173 Utf8Encoding::GetDecoderN(void) const
175 return new (std::nothrow) Utf8Decoder();
180 Utf8Encoding::GetEncodingType(void) const
182 return String(ENCODING_NAME);