tizen 2.3.1 release
[framework/api/base-utils.git] / src / include / wearable / utils_i18n_uchar.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef __UTILS_I18N_UCHAR_H__
18 #define __UTILS_I18N_UCHAR_H__
19
20 #include <utils_i18n_types.h>
21
22 /**
23  * @file utils_i18n_uchar.h
24  * @version 0.1
25  * @brief utils_i18n
26  */
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /**
33  * @ingroup CAPI_BASE_UTILS_I18N_MODULE
34  * @defgroup CAPI_BASE_UTILS_I18N_UCHAR_MODULE Uchar
35  * @brief The Uchar module provides low-level access to the Unicode Character Database.
36  *
37  * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_HEADER Required Header
38  *  \#include <utils_i18n.h>
39  *
40  * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_OVERVIEW Overview
41  * @details The Uchar module provides low-level access to the Unicode Character Database.
42  *
43  * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_SAMPLE_CODE_1 Sample Code 1
44  * @brief Gets the property value of 'east asian width' among an enumerated property,
45  * and the unicode allocation block that contains the character.
46  * @code
47     int ret = I18N_ERROR_NONE;
48     i18n_uchar32 code_point = 0;
49     int property_value = 0;
50     i18n_uchar_u_east_asian_width_e east_asian_width = I18N_UCHAR_U_EA_NEUTRAL;
51     i18n_uchar_ublock_code_e block_code = I18N_UCHAR_UBLOCK_NO_BLOCK;
52
53     // How to get the east asian width type for 's'
54     code_point = 0x73;    // 's'
55     ret = i18n_uchar_get_int_property_value(code_point, I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value);
56     if (ret != I18N_ERROR_NONE) {
57         dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n");
58     } else {
59         east_asian_width = (i18n_uchar_u_east_asian_width_e)property_value;
60         dlog_print(DLOG_INFO, LOG_TAG, "East Asian Width Type for ( %.4x ) is ( %d )\n", code_point, east_asian_width);
61         // East Asian Width Type for ( 0073 ) is ( 4 ) which is I18N_UCHAR_U_EA_NARROW
62     }
63
64     // How to get the block code for 's'
65     ret = i18n_uchar_get_ublock_code(code_point, &block_code);
66     if (ret != I18N_ERROR_NONE) {
67         dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n");
68     } else {
69         dlog_print(DLOG_INFO, LOG_TAG, "block name for ( %.4x ) is ( %d )\n", code_point, block_code);
70         // block code for ( 0073 ) is ( 1 ) which is I18N_UCHAR_UBLOCK_BASIC_LATIN
71     }
72
73     // How to get the east asian width type for 'sung' as ideographs
74     code_point = 0x661F;    // 'sung' as ideographs
75     ret = i18n_uchar_get_int_property_value(code_point, I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value);
76     if (ret != I18N_ERROR_NONE) {
77         dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n");
78     } else {
79         east_asian_width = (i18n_uchar_u_east_asian_width_e)property_value;
80         dlog_print(DLOG_INFO, LOG_TAG, "East Asian Width Type for ( %.4x ) is ( %d )\n", code_point, east_asian_width);
81         // East Asian Width Type for ( 661f ) is ( 5 ) which is I18N_UCHAR_U_EA_WIDE
82     }
83
84     // How to get the block code for 'sung' as ideographs
85     ret = i18n_uchar_get_ublock_code(code_point, &block_code);
86     if (ret != I18N_ERROR_NONE) {
87         dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n");
88     } else {
89         dlog_print(DLOG_INFO, LOG_TAG, "block name for ( %.4x ) is ( %d )\n", code_point, block_code);
90         // block code for ( 661f ) is ( 71 ) which is I18N_UCHAR_UBLOCK_CJK_UNIFIED_IDEOGRAPHS
91     }
92
93     // How to get the east asian width type for 'sung' as hangul
94     code_point = 0xC131;    // 'sung' as hangul
95     ret = i18n_uchar_get_int_property_value(code_point, I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value);
96     if (ret != I18N_ERROR_NONE) {
97         dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n");
98     } else {
99         east_asian_width = (i18n_uchar_u_east_asian_width_e)property_value;
100         dlog_print(DLOG_INFO, LOG_TAG, "East Asian Width Type for ( %.4x ) is ( %d )\n", code_point, east_asian_width);
101         // East Asian Width Type for ( c131 ) is ( 5 ) which is I18N_UCHAR_U_EA_WIDE
102     }
103
104     // How to get the block code for 'sung' as hangul
105     ret = i18n_uchar_get_ublock_code(code_point, &block_code);
106     if (ret != I18N_ERROR_NONE) {
107         dlog_print(DLOG_INFO, LOG_TAG, "Error occured!!\n");
108     } else {
109         dlog_print(DLOG_INFO, LOG_TAG, "block name for ( %.4x ) is ( %d )\n", code_point, block_code);
110         // block code for ( c131 ) is ( 74 ) which is I18N_UCHAR_UBLOCK_HANGUL_SYLLABLES
111     }
112   
113  * @endcode
114  */
115
116 /**
117  * @addtogroup CAPI_BASE_UTILS_I18N_UCHAR_MODULE
118  * @{
119  */
120
121 /**
122  * @brief Gets the property value for an enumerated property for a code point.
123  * @details
124  *     <code>
125  *     int property_value;\n
126  *     #i18n_uchar_u_east_asian_width_e east_asian_width;\n
127  *     #i18n_uchar_get_int_property_value (c, #I18N_UCHAR_EAST_ASIAN_WIDTH, &property_value);\n
128  *     east_asian_width = (#i18n_uchar_u_east_asian_width_e)property_value;\n
129  *
130  *     int property_value;\n
131  *     bool is_ideographic;\n
132  *     #i18n_uchar_get_int_property_value(c, #I18N_UCHAR_IDEOGRAPHIC, &property_value);\n
133  *     is_ideographic = (bool)property_value;\n
134  *     </code>
135  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
136  *
137  * @param[in] c The code point to test.
138  * @param[in] which The #i18n_uchar_uproperty_e selector constant, identifies which property to check \n
139  * Must be #I18N_UCHAR_BINARY_START<=which<#I18N_UCHAR_BINARY_LIMIT
140  * or #I18N_UCHAR_INT_START<=which<#I18N_UCHAR_INT_LIMIT
141  * or #I18N_UCHAR_MASK_START<=which<#I18N_UCHAR_MASK_LIMIT.
142  * @param[out] property_val The numeric value that is directly the property value or,
143  * for enumerated properties, corresponds to the numeric value of the enumerated
144  * constant of the respective property value enumeration type (cast to enum type if necessary)\n
145  * Returns @c 0 or @c 1 (for false/true) for binary Unicode properties\n
146  * Returns a bit-mask for mask properties \n
147  * Returns @c 0 if 'which' is out of bounds or if the Unicode version does not have data for the property at all, or not for this code point.
148  *
149  * @retval #I18N_ERROR_NONE Successful
150  * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
151  */
152 int i18n_uchar_get_int_property_value ( i18n_uchar32 c, i18n_uchar_uproperty_e which, int32_t *property_val );
153
154 /**
155  * @brief Gets the Unicode allocation block that contains the character.
156  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
157  *
158  * @param[in] c The code point to test
159  * @param[out] block_val The block value for the code point
160  *
161  * @retval #I18N_ERROR_NONE  Successful
162  * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
163  */
164 int i18n_uchar_get_ublock_code ( i18n_uchar32 c, i18n_uchar_ublock_code_e *block_val );
165
166 #ifdef __cplusplus
167 }
168 #endif
169
170 /**
171  * @}
172  * @}
173  */
174
175 #endif  /* __UTILS_I18N_UCHAR_H__*/