2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FTextUtf8Encoding.cpp
19 * @brief This is the implementation file for UTF-8 Encoding class.
22 #include <FTextUtf8Encoding.h>
23 #include <FBaseSysLog.h>
24 #include "FText_EncodingImpl.h"
27 #define ENCODING_NAME L"UTF-8"
29 using namespace Tizen::Base;
31 namespace Tizen { namespace Text
35 Utf8Encoding::Utf8Encoding(void)
36 : __pUtf8EncodingImpl(null)
38 _pEncodingImpl = new (std::nothrow) _EncodingImpl;
41 result r = _pEncodingImpl->Construct(ENCODING_NAME);
44 delete _pEncodingImpl;
45 _pEncodingImpl = null;
49 SysAssert(_pEncodingImpl);
53 Utf8Encoding::~Utf8Encoding(void)
55 delete _pEncodingImpl;
60 Utf8Encoding::GetByteCount(const String& str, int& byteCount) const
62 return _pEncodingImpl->GetByteCount(str, byteCount);
67 Utf8Encoding::GetByteCount(const WcharBuffer& chars, int& byteCount) const
69 return _pEncodingImpl->GetByteCount(chars, byteCount);
74 Utf8Encoding::GetByteCount(const WcharBuffer& chars, int charIndex, int charCount, int& byteCount) const
76 return _pEncodingImpl->GetByteCount(chars, charIndex, charCount, byteCount);
81 Utf8Encoding::GetBytesN(const WcharBuffer& chars) const
83 return _pEncodingImpl->GetBytesN(chars);
88 Utf8Encoding::GetBytesN(const String& str) const
90 return _pEncodingImpl->GetBytesN(str);
95 Utf8Encoding::GetBytes(const WcharBuffer& chars, int charIndex, int charCount, ByteBuffer& bytes, int byteIndex) const
97 return _pEncodingImpl->GetBytes(chars, charIndex, charCount, bytes, byteIndex);
102 Utf8Encoding::GetBytes(const String& str, int charIndex, int charCount, ByteBuffer& bytes, int byteIndex) const
104 return _pEncodingImpl->GetBytes(str, charIndex, charCount, bytes, byteIndex);
109 Utf8Encoding::GetCharCount(const ByteBuffer& bytes, int& charCount) const
111 return _pEncodingImpl->GetCharCount(bytes, charCount);
116 Utf8Encoding::GetCharCount(const ByteBuffer& bytes, int byteIndex, int byteCount, int& charCount) const
118 return _pEncodingImpl->GetCharCount(bytes, byteIndex, byteCount, charCount);
123 Utf8Encoding::GetCharsN(const ByteBuffer& bytes) const
125 return _pEncodingImpl->GetCharsN(bytes);
130 Utf8Encoding::GetChars(const ByteBuffer& bytes, int byteIndex, int byteCount, WcharBuffer& chars, int charIndex) const
132 return _pEncodingImpl->GetChars(bytes, byteIndex, byteCount, chars, charIndex);
137 Utf8Encoding::GetString(const ByteBuffer& bytes, String& str) const
139 return _pEncodingImpl->GetString(bytes, str);
144 Utf8Encoding::GetString(const ByteBuffer& bytes, int byteIndex, int byteCount, String& str) const
146 return _pEncodingImpl->GetString(bytes, byteIndex, byteCount, str);
151 Utf8Encoding::GetMaxByteCount(int charCount) const
153 return charCount * 3;
158 Utf8Encoding::GetMaxCharCount(int byteCount) const
165 Utf8Encoding::GetEncoderN(void) const
167 return new (std::nothrow) Utf8Encoder();
172 Utf8Encoding::GetDecoderN(void) const
174 return new (std::nothrow) Utf8Decoder();
179 Utf8Encoding::GetEncodingType(void) const
181 return String(ENCODING_NAME);