intl/icu/source/common/unistr_case_locale.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial