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 #include <unicode/ucol.h>
18 #include <utils_i18n_ucollator.h>
19 #include <utils_i18n_private.h>
21 int i18n_ucollator_destroy ( i18n_ucollator_h collator )
23 retv_if(collator == NULL, I18N_ERROR_INVALID_PARAMETER);
27 return I18N_ERROR_NONE;
30 int i18n_ucollator_equal ( const i18n_ucollator_h collator, const i18n_uchar *src, int32_t src_len, const i18n_uchar *target, int32_t target_len, i18n_ubool *equal )
32 retv_if(collator == NULL, I18N_ERROR_INVALID_PARAMETER);
34 *equal = ucol_equal(collator, src, src_len, target, target_len);
36 return I18N_ERROR_NONE;
39 int i18n_ucollator_create ( const char *locale, i18n_ucollator_h *collator )
41 retv_if (collator == NULL, I18N_ERROR_INVALID_PARAMETER);
43 i18n_error_code_e err = I18N_ERROR_NONE;
44 *collator = ucol_open(locale, (UErrorCode*)&err);
45 int result = _i18n_error_mapping(err);
50 int i18n_ucollator_set_attribute( i18n_ucollator_h collator, i18n_ucollator_attribute_e attr, i18n_ucollator_attribute_value_e val )
52 retv_if(collator == NULL, I18N_ERROR_INVALID_PARAMETER);
54 i18n_error_code_e err = I18N_ERROR_NONE;
55 ucol_setAttribute(collator, attr, val, (UErrorCode*)&err);
56 int result = _i18n_error_mapping(err);
61 int i18n_ucollator_set_strength ( i18n_ucollator_h collator, i18n_ucollator_strength_e strength )
63 retv_if(collator == NULL, I18N_ERROR_INVALID_PARAMETER);
65 ucol_setStrength(collator, strength);
67 return I18N_ERROR_NONE;
70 int i18n_ucollator_str_collator ( const i18n_ucollator_h collator, const i18n_uchar *src, int32_t src_len, const i18n_uchar *target, int32_t target_len, i18n_ucollator_result_e *result )
72 retv_if(collator == NULL, I18N_ERROR_INVALID_PARAMETER);
74 *result = ucol_strcoll(collator, src, src_len, target, target_len);
76 return I18N_ERROR_NONE;