1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2011, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: ustrcase_locale.cpp
10 * tab size: 8 (not used)
13 * created on: 2011may31
14 * created by: Markus W. Scherer
16 * Locale-sensitive case mapping functions (ones that call uloc_getDefault())
17 * were moved here to break dependency cycles among parts of the common library.
20 #include "unicode/utypes.h"
22 #include "unicode/brkiter.h"
23 #include "unicode/casemap.h"
24 #include "unicode/ucasemap.h"
25 #include "unicode/uloc.h"
26 #include "unicode/ustring.h"
28 #include "ucasemap_imp.h"
31 ustrcase_getCaseLocale(const char *locale
) {
33 locale
= uloc_getDefault();
36 return UCASE_LOC_ROOT
;
38 return ucase_getCaseLocale(locale
);
42 /* public API functions */
44 U_CAPI
int32_t U_EXPORT2
45 u_strToLower(UChar
*dest
, int32_t destCapacity
,
46 const UChar
*src
, int32_t srcLength
,
48 UErrorCode
*pErrorCode
) {
49 return ustrcase_mapWithOverlap(
50 ustrcase_getCaseLocale(locale
), 0, UCASEMAP_BREAK_ITERATOR_NULL
53 ustrcase_internalToLower
, *pErrorCode
);
56 U_CAPI
int32_t U_EXPORT2
57 u_strToUpper(UChar
*dest
, int32_t destCapacity
,
58 const UChar
*src
, int32_t srcLength
,
60 UErrorCode
*pErrorCode
) {
61 return ustrcase_mapWithOverlap(
62 ustrcase_getCaseLocale(locale
), 0, UCASEMAP_BREAK_ITERATOR_NULL
65 ustrcase_internalToUpper
, *pErrorCode
);
70 int32_t CaseMap::toLower(
71 const char *locale
, uint32_t options
,
72 const UChar
*src
, int32_t srcLength
,
73 UChar
*dest
, int32_t destCapacity
, Edits
*edits
,
74 UErrorCode
&errorCode
) {
76 ustrcase_getCaseLocale(locale
), options
, UCASEMAP_BREAK_ITERATOR_NULL
79 ustrcase_internalToLower
, edits
, errorCode
);
82 int32_t CaseMap::toUpper(
83 const char *locale
, uint32_t options
,
84 const UChar
*src
, int32_t srcLength
,
85 UChar
*dest
, int32_t destCapacity
, Edits
*edits
,
86 UErrorCode
&errorCode
) {
88 ustrcase_getCaseLocale(locale
), options
, UCASEMAP_BREAK_ITERATOR_NULL
91 ustrcase_internalToUpper
, edits
, errorCode
);