Merge "Combine Internal::ProxyObject & Internal::Object" into tizen
[platform/core/uifw/dali-core.git] / dali / internal / event / text / utf8-impl.h
1 #ifndef __DALI_INTERNAL_UTF8_H__
2 #define __DALI_INTERNAL_UTF8_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/integration-api/text-array.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 /**
31  * Determine the length (in bytes) of a UTF-8 character
32  * @param[in] leadByte The lead byte of a UTF-8 character sequence
33  * @return The length of the sequence, or zero if the UTF-8 character is invalid.
34  */
35 size_t UTF8SequenceLength(const unsigned char leadByte);
36
37 /**
38  * Converts a UTF-8 character into a UTF-32 code
39  * @param[in] utf8Data       A pointer to the lead byte of the UTF-8 character
40  * @param[in] sequenceLength The length of the UTF-8 character. See UTF8SequenceLength.
41  * @return The UTF-32 code, (or zero if the sequenceLength is not between 1..4
42  */
43 uint32_t UTF8Read(const unsigned char* utf8Data, const size_t sequenceLength);
44
45 /**
46  * Converts a UTF-32 code into a UTF-8 sequence
47  * @param[in]  code     The UTF-32 code
48  * @param[out] utf8Data The UTF-8 buffer that receives the sequence
49  * @return The length of the sequence written to utf8Data, or zero if the code was invalid
50  */
51 size_t UTF8Write(const uint32_t code, unsigned char* utf8Data);
52
53 /**
54  * Converts a stream of UTF-8 codes into an aarray of UTF-32 codes
55  * @param[in]  utf8Data       The UTF-8 buffer containing the UTF-8 string
56  * @param[in]  utf8DataLength The size of the data, in bytes, at utf8Data
57  * @param[out] tokens         A vector which will receive the converted UTF-32 codes
58  * @return The number of UTF-32 codes.
59  */
60 size_t UTF8Tokenize(const unsigned char* utf8Data, const size_t utf8DataLength, Integration::TextArray& tokens);
61
62 } // namespace Internal
63
64 } // namespace Dali
65
66 #endif // __DALI_INTERNAL_UTF8_H__
67