intl/icu/source/common/unistr_case_locale.cpp

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /*
     2 *******************************************************************************
     3 *   Copyright (C) 2011, International Business Machines
     4 *   Corporation and others.  All Rights Reserved.
     5 *******************************************************************************
     6 *   file name:  unistr_case_locale.cpp
     7 *   encoding:   US-ASCII
     8 *   tab size:   8 (not used)
     9 *   indentation:4
    10 *
    11 *   created on: 2011may31
    12 *   created by: Markus W. Scherer
    13 *
    14 *   Locale-sensitive case mapping functions (ones that call uloc_getDefault())
    15 *   were moved here to break dependency cycles among parts of the common library.
    16 */
    18 #include "unicode/utypes.h"
    19 #include "unicode/locid.h"
    20 #include "unicode/unistr.h"
    21 #include "cmemory.h"
    22 #include "ustr_imp.h"
    24 U_NAMESPACE_BEGIN
    26 //========================================
    27 // Write implementation
    28 //========================================
    30 /*
    31  * Set parameters on an empty UCaseMap, for UCaseMap-less API functions.
    32  * Do this fast because it is called with every function call.
    33  */
    34 static inline void
    35 setTempCaseMap(UCaseMap *csm, const char *locale) {
    36     if(csm->csp==NULL) {
    37         csm->csp=ucase_getSingleton();
    38     }
    39     if(locale!=NULL && locale[0]==0) {
    40         csm->locale[0]=0;
    41     } else {
    42         ustrcase_setTempCaseMapLocale(csm, locale);
    43     }
    44 }
    46 UnicodeString &
    47 UnicodeString::toLower() {
    48   return toLower(Locale::getDefault());
    49 }
    51 UnicodeString &
    52 UnicodeString::toLower(const Locale &locale) {
    53   UCaseMap csm=UCASEMAP_INITIALIZER;
    54   setTempCaseMap(&csm, locale.getName());
    55   return caseMap(&csm, ustrcase_internalToLower);
    56 }
    58 UnicodeString &
    59 UnicodeString::toUpper() {
    60   return toUpper(Locale::getDefault());
    61 }
    63 UnicodeString &
    64 UnicodeString::toUpper(const Locale &locale) {
    65   UCaseMap csm=UCASEMAP_INITIALIZER;
    66   setTempCaseMap(&csm, locale.getName());
    67   return caseMap(&csm, ustrcase_internalToUpper);
    68 }
    70 U_NAMESPACE_END

mercurial