1 // Copyright (C) 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: unistr_case_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"
21 #include "unicode/locid.h"
22 #include "unicode/unistr.h"
28 //========================================
29 // Write implementation
30 //========================================
33 * Set parameters on an empty UCaseMap, for UCaseMap-less API functions.
34 * Do this fast because it is called with every function call.
37 setTempCaseMap(UCaseMap *csm, const char *locale) {
39 csm->csp=ucase_getSingleton();
41 if(locale!=NULL && locale[0]==0) {
44 ustrcase_setTempCaseMapLocale(csm, locale);
49 UnicodeString::toLower() {
50 return toLower(Locale::getDefault());
54 UnicodeString::toLower(const Locale &locale) {
55 UCaseMap csm=UCASEMAP_INITIALIZER;
56 setTempCaseMap(&csm, locale.getName());
57 return caseMap(&csm, ustrcase_internalToLower);
61 UnicodeString::toUpper() {
62 return toUpper(Locale::getDefault());
66 UnicodeString::toUpper(const Locale &locale) {
67 UCaseMap csm=UCASEMAP_INITIALIZER;
68 setTempCaseMap(&csm, locale.getName());
69 return caseMap(&csm, ustrcase_internalToUpper);