11cb0ef41Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 21cb0ef41Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 31cb0ef41Sopenharmony_ci/* 41cb0ef41Sopenharmony_ci******************************************************************************* 51cb0ef41Sopenharmony_ci* Copyright (C) 2011, International Business Machines 61cb0ef41Sopenharmony_ci* Corporation and others. All Rights Reserved. 71cb0ef41Sopenharmony_ci******************************************************************************* 81cb0ef41Sopenharmony_ci* file name: ustrcase_locale.cpp 91cb0ef41Sopenharmony_ci* encoding: UTF-8 101cb0ef41Sopenharmony_ci* tab size: 8 (not used) 111cb0ef41Sopenharmony_ci* indentation:4 121cb0ef41Sopenharmony_ci* 131cb0ef41Sopenharmony_ci* created on: 2011may31 141cb0ef41Sopenharmony_ci* created by: Markus W. Scherer 151cb0ef41Sopenharmony_ci* 161cb0ef41Sopenharmony_ci* Locale-sensitive case mapping functions (ones that call uloc_getDefault()) 171cb0ef41Sopenharmony_ci* were moved here to break dependency cycles among parts of the common library. 181cb0ef41Sopenharmony_ci*/ 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci#include "unicode/utypes.h" 211cb0ef41Sopenharmony_ci#include "uassert.h" 221cb0ef41Sopenharmony_ci#include "unicode/brkiter.h" 231cb0ef41Sopenharmony_ci#include "unicode/casemap.h" 241cb0ef41Sopenharmony_ci#include "unicode/ucasemap.h" 251cb0ef41Sopenharmony_ci#include "unicode/uloc.h" 261cb0ef41Sopenharmony_ci#include "unicode/ustring.h" 271cb0ef41Sopenharmony_ci#include "ucase.h" 281cb0ef41Sopenharmony_ci#include "ucasemap_imp.h" 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ciU_CFUNC int32_t 311cb0ef41Sopenharmony_ciustrcase_getCaseLocale(const char *locale) { 321cb0ef41Sopenharmony_ci if (locale == nullptr) { 331cb0ef41Sopenharmony_ci locale = uloc_getDefault(); 341cb0ef41Sopenharmony_ci } 351cb0ef41Sopenharmony_ci if (*locale == 0) { 361cb0ef41Sopenharmony_ci return UCASE_LOC_ROOT; 371cb0ef41Sopenharmony_ci } else { 381cb0ef41Sopenharmony_ci return ucase_getCaseLocale(locale); 391cb0ef41Sopenharmony_ci } 401cb0ef41Sopenharmony_ci} 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci/* public API functions */ 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2 451cb0ef41Sopenharmony_ciu_strToLower(char16_t *dest, int32_t destCapacity, 461cb0ef41Sopenharmony_ci const char16_t *src, int32_t srcLength, 471cb0ef41Sopenharmony_ci const char *locale, 481cb0ef41Sopenharmony_ci UErrorCode *pErrorCode) { 491cb0ef41Sopenharmony_ci return ustrcase_mapWithOverlap( 501cb0ef41Sopenharmony_ci ustrcase_getCaseLocale(locale), 0, UCASEMAP_BREAK_ITERATOR_NULL 511cb0ef41Sopenharmony_ci dest, destCapacity, 521cb0ef41Sopenharmony_ci src, srcLength, 531cb0ef41Sopenharmony_ci ustrcase_internalToLower, *pErrorCode); 541cb0ef41Sopenharmony_ci} 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2 571cb0ef41Sopenharmony_ciu_strToUpper(char16_t *dest, int32_t destCapacity, 581cb0ef41Sopenharmony_ci const char16_t *src, int32_t srcLength, 591cb0ef41Sopenharmony_ci const char *locale, 601cb0ef41Sopenharmony_ci UErrorCode *pErrorCode) { 611cb0ef41Sopenharmony_ci return ustrcase_mapWithOverlap( 621cb0ef41Sopenharmony_ci ustrcase_getCaseLocale(locale), 0, UCASEMAP_BREAK_ITERATOR_NULL 631cb0ef41Sopenharmony_ci dest, destCapacity, 641cb0ef41Sopenharmony_ci src, srcLength, 651cb0ef41Sopenharmony_ci ustrcase_internalToUpper, *pErrorCode); 661cb0ef41Sopenharmony_ci} 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_ciU_NAMESPACE_BEGIN 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ciint32_t CaseMap::toLower( 711cb0ef41Sopenharmony_ci const char *locale, uint32_t options, 721cb0ef41Sopenharmony_ci const char16_t *src, int32_t srcLength, 731cb0ef41Sopenharmony_ci char16_t *dest, int32_t destCapacity, Edits *edits, 741cb0ef41Sopenharmony_ci UErrorCode &errorCode) { 751cb0ef41Sopenharmony_ci return ustrcase_map( 761cb0ef41Sopenharmony_ci ustrcase_getCaseLocale(locale), options, UCASEMAP_BREAK_ITERATOR_NULL 771cb0ef41Sopenharmony_ci dest, destCapacity, 781cb0ef41Sopenharmony_ci src, srcLength, 791cb0ef41Sopenharmony_ci ustrcase_internalToLower, edits, errorCode); 801cb0ef41Sopenharmony_ci} 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ciint32_t CaseMap::toUpper( 831cb0ef41Sopenharmony_ci const char *locale, uint32_t options, 841cb0ef41Sopenharmony_ci const char16_t *src, int32_t srcLength, 851cb0ef41Sopenharmony_ci char16_t *dest, int32_t destCapacity, Edits *edits, 861cb0ef41Sopenharmony_ci UErrorCode &errorCode) { 871cb0ef41Sopenharmony_ci return ustrcase_map( 881cb0ef41Sopenharmony_ci ustrcase_getCaseLocale(locale), options, UCASEMAP_BREAK_ITERATOR_NULL 891cb0ef41Sopenharmony_ci dest, destCapacity, 901cb0ef41Sopenharmony_ci src, srcLength, 911cb0ef41Sopenharmony_ci ustrcase_internalToUpper, edits, errorCode); 921cb0ef41Sopenharmony_ci} 931cb0ef41Sopenharmony_ci 941cb0ef41Sopenharmony_ciU_NAMESPACE_END 95