Resolve incorrect position for Ellipsis when mixed LTR & RTL languages and set layout...
[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) 2021 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 namespace Toolkit
28 {
29 namespace Text
30 {
31 /**
32  * @brief Retrieves the number of bytes of a utf8 character.
33  *
34  * @param[in] utf8LeadByte The lead byte of the utf8 character.
35  *
36  * @return The number of bytes of the character.
37  */
38 uint8_t GetUtf8Length(uint8_t utf8LeadByte);
39
40 /**
41  * @brief Retrieves the number of characters of the text array encoded in UTF8
42  *
43  * @param[in] utf8 The pointer to the UTF8 array.
44  * @param[in] length The length of the UTF8 array.
45  *
46  * @return The number of characters.
47  */
48 uint32_t GetNumberOfUtf8Characters(const uint8_t* const utf8, uint32_t length);
49
50 /**
51  * @brief Retrieves the number of bytes needed to encode in UTF8 the given text array encoded in UTF32.
52  *
53  * @param[in] utf32 The pointer to the UTF32 array.
54  * @param[in] numberOfCharacters The number of characters of the UTF32 array.
55  *
56  * @return The number of bytes.
57  */
58 uint32_t GetNumberOfUtf8Bytes(const uint32_t* const utf32, uint32_t numberOfCharacters);
59
60 /**
61  * @brief Converts a text array encoded in UTF8 into a text array encoded in UTF32.
62  *
63  * The @p utf32 buffer needs to be big enough to store all the characters.
64  *
65  * If the text contains a single 'CR' character or a pair 'CR'+'LF', they are replaced by a 'LF'.
66  *
67  * @note GetNumberOfUtf8Characters() does not convert 'CR' or 'CR'+'LF' to 'LF' so the return number
68  * of characters of that method may be higher than the number of characters returned by this one.
69  *
70  * @param[in] utf8 The pointer to the UTF8 array.
71  * @param[in] length The length of the UTF8 array.
72  * @param[out] utf32 The pointer to the UTF32 array.
73  *
74  * @return The number of characters.
75  */
76 uint32_t Utf8ToUtf32(const uint8_t* const utf8, uint32_t length, uint32_t* utf32);
77
78 /**
79  * @brief Converts a text array encoded in UTF32 into a text array encoded in UTF8.
80  *
81  * The @p utf8 buffer needs to be big enough to store all the characters.
82  *
83  * @param[in] utf32 The pointer to the UTF32 array.
84  * @param[in] numberOfCharacters The number of characters of the UTF32 array.
85  * @param[out] utf8 The pointer to the UTF8 array.
86  *
87  * @return The number of bytes.
88  */
89 uint32_t Utf32ToUtf8(const uint32_t* const utf32, uint32_t numberOfCharacters, uint8_t* utf8);
90
91 /**
92  * @brief Converts a text array encoded in UTF32 into a text array encoded in UTF8.
93  *
94  * @param[in] utf32 The pointer to the UTF32 array.
95  * @param[in] numberOfCharacters The number of characters of the UTF32 array.
96  * @param[out] utf8 The UTF8 characters will be stored here.
97  */
98 void Utf32ToUtf8(const uint32_t* const utf32, uint32_t numberOfCharacters, std::string& utf8);
99
100 } // namespace Text
101
102 } // namespace Toolkit
103
104 } // namespace Dali
105
106 #endif // DALI_TOOLKIT_CHARACTER_SET_CONVERSION_H