2017-01-20 00:20:31 +00:00
|
|
|
// © 2016 and later: Unicode, Inc. and others.
|
2016-06-15 18:58:17 +00:00
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
2011-06-03 05:23:57 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
2016-05-31 21:45:07 +00:00
|
|
|
* Copyright (C) 2011, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
2011-06-03 05:23:57 +00:00
|
|
|
*******************************************************************************
|
|
|
|
* file name: ustrcase_locale.cpp
|
2017-02-03 18:57:23 +00:00
|
|
|
* encoding: UTF-8
|
2011-06-03 05:23:57 +00:00
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2011may31
|
|
|
|
* created by: Markus W. Scherer
|
|
|
|
*
|
|
|
|
* Locale-sensitive case mapping functions (ones that call uloc_getDefault())
|
|
|
|
* were moved here to break dependency cycles among parts of the common library.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
2017-01-12 19:05:01 +00:00
|
|
|
#include "uassert.h"
|
|
|
|
#include "unicode/brkiter.h"
|
2017-02-09 21:15:34 +00:00
|
|
|
#include "unicode/casemap.h"
|
2011-06-03 05:23:57 +00:00
|
|
|
#include "unicode/ucasemap.h"
|
|
|
|
#include "unicode/uloc.h"
|
|
|
|
#include "unicode/ustring.h"
|
|
|
|
#include "ucase.h"
|
2017-02-09 21:15:34 +00:00
|
|
|
#include "ucasemap_imp.h"
|
2011-06-03 05:23:57 +00:00
|
|
|
|
2017-01-20 04:04:58 +00:00
|
|
|
U_CFUNC int32_t
|
|
|
|
ustrcase_getCaseLocale(const char *locale) {
|
|
|
|
if (locale == NULL) {
|
|
|
|
locale = uloc_getDefault();
|
2011-06-03 05:23:57 +00:00
|
|
|
}
|
2017-01-20 04:04:58 +00:00
|
|
|
if (*locale == 0) {
|
|
|
|
return UCASE_LOC_ROOT;
|
2011-06-03 05:23:57 +00:00
|
|
|
} else {
|
2017-01-20 06:27:47 +00:00
|
|
|
return ucase_getCaseLocale(locale);
|
2011-06-03 05:23:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* public API functions */
|
|
|
|
|
|
|
|
U_CAPI int32_t U_EXPORT2
|
|
|
|
u_strToLower(UChar *dest, int32_t destCapacity,
|
|
|
|
const UChar *src, int32_t srcLength,
|
|
|
|
const char *locale,
|
|
|
|
UErrorCode *pErrorCode) {
|
2017-01-06 00:20:31 +00:00
|
|
|
return ustrcase_mapWithOverlap(
|
2017-01-20 04:04:58 +00:00
|
|
|
ustrcase_getCaseLocale(locale), 0, UCASEMAP_BREAK_ITERATOR_NULL
|
2011-06-03 05:23:57 +00:00
|
|
|
dest, destCapacity,
|
|
|
|
src, srcLength,
|
2017-01-09 23:52:12 +00:00
|
|
|
ustrcase_internalToLower, *pErrorCode);
|
2011-06-03 05:23:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
U_CAPI int32_t U_EXPORT2
|
|
|
|
u_strToUpper(UChar *dest, int32_t destCapacity,
|
|
|
|
const UChar *src, int32_t srcLength,
|
|
|
|
const char *locale,
|
|
|
|
UErrorCode *pErrorCode) {
|
2017-01-06 00:20:31 +00:00
|
|
|
return ustrcase_mapWithOverlap(
|
2017-01-20 04:04:58 +00:00
|
|
|
ustrcase_getCaseLocale(locale), 0, UCASEMAP_BREAK_ITERATOR_NULL
|
2011-06-03 05:23:57 +00:00
|
|
|
dest, destCapacity,
|
|
|
|
src, srcLength,
|
2017-01-09 23:52:12 +00:00
|
|
|
ustrcase_internalToUpper, *pErrorCode);
|
2011-06-03 05:23:57 +00:00
|
|
|
}
|
2017-01-20 04:04:58 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
int32_t CaseMap::toLower(
|
|
|
|
const char *locale, uint32_t options,
|
|
|
|
const UChar *src, int32_t srcLength,
|
|
|
|
UChar *dest, int32_t destCapacity, Edits *edits,
|
|
|
|
UErrorCode &errorCode) {
|
|
|
|
return ustrcase_map(
|
|
|
|
ustrcase_getCaseLocale(locale), options, UCASEMAP_BREAK_ITERATOR_NULL
|
|
|
|
dest, destCapacity,
|
|
|
|
src, srcLength,
|
|
|
|
ustrcase_internalToLower, edits, errorCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t CaseMap::toUpper(
|
|
|
|
const char *locale, uint32_t options,
|
|
|
|
const UChar *src, int32_t srcLength,
|
|
|
|
UChar *dest, int32_t destCapacity, Edits *edits,
|
|
|
|
UErrorCode &errorCode) {
|
2011-06-03 05:23:57 +00:00
|
|
|
return ustrcase_map(
|
2017-01-20 04:04:58 +00:00
|
|
|
ustrcase_getCaseLocale(locale), options, UCASEMAP_BREAK_ITERATOR_NULL
|
2011-06-03 05:23:57 +00:00
|
|
|
dest, destCapacity,
|
|
|
|
src, srcLength,
|
2017-01-20 04:04:58 +00:00
|
|
|
ustrcase_internalToUpper, edits, errorCode);
|
2011-06-03 05:23:57 +00:00
|
|
|
}
|
2017-01-20 04:04:58 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_END
|