720114b1e1b0080cd6c16919c4445f9dd2c6d204
[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 // INTERNAL INCLUDES
26 #include <dali/public-api/common/dali-common.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Text
35 {
36
37 /**
38  * @brief Retrieves the number of characters of the text array encoded in UTF8
39  *
40  * @param[in] utf8 The pointer to the UTF8 array.
41  * @param[in] length The length of the UTF8 array.
42  *
43  * @return The number of characters.
44  */
45 uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, uint32_t length );
46
47 /**
48  * @brief Retrieves the number of bytes needed to encode in UTF8 the given text array encoded in UTF32.
49  *
50  * @param[in] utf32 The pointer to the UTF32 array.
51  * @param[in] numberOfCharacters The number of characters of the UTF32 array.
52  *
53  * @return The number of bytes.
54  */
55 uint32_t GetNumberOfUtf8Bytes( const uint32_t* const utf32, uint32_t numberOfCharacters );
56
57 /**
58  * @brief Converts a text array encoded in UTF8 into a text array encoded in UTF32.
59  *
60  * The @p utf32 buffer needs to be big enough to store all the characters.
61  *
62  * @param[in] utf8 The pointer to the UTF8 array.
63  * @param[in] length The length of the UTF8 array.
64  * @param[out] utf32 The pointer to the UTF32 array.
65  *
66  * @return The number of characters.
67  */
68 uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf32 );
69
70 /**
71  * @brief Converts a text array encoded in UTF32 into a text array encoded in UTF8.
72  *
73  * The @p utf8 buffer needs to be big enough to store all the characters.
74  *
75  * @param[in] utf32 The pointer to the UTF32 array.
76  * @param[in] numberOfCharacters The number of characters of the UTF32 array.
77  * @param[out] utf8 The pointer to the UTF8 array.
78  *
79  * @return The number of bytes.
80  */
81 uint32_t Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, uint8_t* utf8 );
82
83 /**
84  * @brief Converts a text array encoded in UTF32 into a text array encoded in UTF8.
85  *
86  * @param[in] utf32 The pointer to the UTF32 array.
87  * @param[in] numberOfCharacters The number of characters of the UTF32 array.
88  * @param[out] utf8 The UTF8 characters will be stored here.
89  */
90 void Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, std::string& utf8 );
91
92 } // namespace Text
93
94 } // namespace Toolkit
95
96 } // namespace Dali
97
98 #endif // __DALI_TOOLKIT_CHARACTER_SET_CONVERSION_H__