Markup processor.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / character-set-conversion.h
1 #ifndef __DALI_TOOLKIT_CHARACTER_SET_CONVERSION_H__
2 #define __DALI_TOOLKIT_CHARACTER_SET_CONVERSION_H__
3
4 /*
5  * Copyright (c) 2015 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 // EXTERNAL INCLUDES
22 #include <stdint.h>
23 #include <string>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Text
32 {
33
34 /**
35  * @brief Retrieves the number of bytes of a utf8 character.
36  *
37  * @param[in] utf8LeadByte The lead byte of the utf8 character.
38  *
39  * @return The number of bytes of the character.
40  */
41 uint8_t GetUtf8Length( uint8_t utf8LeadByte );
42
43 /**
44  * @brief Retrieves the number of characters of the text array encoded in UTF8
45  *
46  * @param[in] utf8 The pointer to the UTF8 array.
47  * @param[in] length The length of the UTF8 array.
48  *
49  * @return The number of characters.
50  */
51 uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, uint32_t length );
52
53 /**
54  * @brief Retrieves the number of bytes needed to encode in UTF8 the given text array encoded in UTF32.
55  *
56  * @param[in] utf32 The pointer to the UTF32 array.
57  * @param[in] numberOfCharacters The number of characters of the UTF32 array.
58  *
59  * @return The number of bytes.
60  */
61 uint32_t GetNumberOfUtf8Bytes( const uint32_t* const utf32, uint32_t numberOfCharacters );
62
63 /**
64  * @brief Converts a text array encoded in UTF8 into a text array encoded in UTF32.
65  *
66  * The @p utf32 buffer needs to be big enough to store all the characters.
67  *
68  * @param[in] utf8 The pointer to the UTF8 array.
69  * @param[in] length The length of the UTF8 array.
70  * @param[out] utf32 The pointer to the UTF32 array.
71  *
72  * @return The number of characters.
73  */
74 uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf32 );
75
76 /**
77  * @brief Converts a text array encoded in UTF32 into a text array encoded in UTF8.
78  *
79  * The @p utf8 buffer needs to be big enough to store all the characters.
80  *
81  * @param[in] utf32 The pointer to the UTF32 array.
82  * @param[in] numberOfCharacters The number of characters of the UTF32 array.
83  * @param[out] utf8 The pointer to the UTF8 array.
84  *
85  * @return The number of bytes.
86  */
87 uint32_t Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, uint8_t* utf8 );
88
89 /**
90  * @brief Converts a text array encoded in UTF32 into a text array encoded in UTF8.
91  *
92  * @param[in] utf32 The pointer to the UTF32 array.
93  * @param[in] numberOfCharacters The number of characters of the UTF32 array.
94  * @param[out] utf8 The UTF8 characters will be stored here.
95  */
96 void Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, std::string& utf8 );
97
98 } // namespace Text
99
100 } // namespace Toolkit
101
102 } // namespace Dali
103
104 #endif // __DALI_TOOLKIT_CHARACTER_SET_CONVERSION_H__