2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __UTILS_I18N_UCHAR_H__
18 #define __UTILS_I18N_UCHAR_H__
20 #include <utils_i18n_types.h>
23 * @file utils_i18n_uchar.h
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.
37 * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_HEADER Required Header
38 * \#include <utils_i18n.h>
40 * @section CAPI_BASE_UTILS_I18N_UCHAR_MODULE_OVERVIEW Overview
41 * @details The Uchar module provides low-level access to the Unicode Character Database.
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.
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;
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");
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
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");
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
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");
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
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");
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
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");
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
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");
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
117 * @addtogroup CAPI_BASE_UTILS_I18N_UCHAR_MODULE
122 * @brief Gets the property value for an enumerated property for a code point.
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
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
135 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
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.
149 * @retval #I18N_ERROR_NONE Successful
150 * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
152 int i18n_uchar_get_int_property_value ( i18n_uchar32 c, i18n_uchar_uproperty_e which, int32_t *property_val );
155 * @brief Gets the Unicode allocation block that contains the character.
156 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
158 * @param[in] c The code point to test
159 * @param[out] block_val The block value for the code point
161 * @retval #I18N_ERROR_NONE Successful
162 * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
164 int i18n_uchar_get_ublock_code ( i18n_uchar32 c, i18n_uchar_ublock_code_e *block_val );
175 #endif /* __UTILS_I18N_UCHAR_H__*/