]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
4388f060 A |
3 | /* |
4 | ******************************************************************************* | |
5 | * Copyright (C) 2011, International Business Machines | |
6 | * Corporation and others. All Rights Reserved. | |
7 | ******************************************************************************* | |
8 | * file name: ustrcase_locale.cpp | |
f3c0d7a5 | 9 | * encoding: UTF-8 |
4388f060 A |
10 | * tab size: 8 (not used) |
11 | * indentation:4 | |
12 | * | |
13 | * created on: 2011may31 | |
14 | * created by: Markus W. Scherer | |
15 | * | |
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. | |
18 | */ | |
19 | ||
20 | #include "unicode/utypes.h" | |
f3c0d7a5 A |
21 | #include "uassert.h" |
22 | #include "unicode/brkiter.h" | |
23 | #include "unicode/casemap.h" | |
4388f060 A |
24 | #include "unicode/ucasemap.h" |
25 | #include "unicode/uloc.h" | |
26 | #include "unicode/ustring.h" | |
27 | #include "ucase.h" | |
f3c0d7a5 | 28 | #include "ucasemap_imp.h" |
4388f060 | 29 | |
f3c0d7a5 A |
30 | U_CFUNC int32_t |
31 | ustrcase_getCaseLocale(const char *locale) { | |
32 | if (locale == NULL) { | |
33 | locale = uloc_getDefault(); | |
4388f060 | 34 | } |
f3c0d7a5 A |
35 | if (*locale == 0) { |
36 | return UCASE_LOC_ROOT; | |
4388f060 | 37 | } else { |
f3c0d7a5 | 38 | return ucase_getCaseLocale(locale); |
4388f060 A |
39 | } |
40 | } | |
41 | ||
42 | /* public API functions */ | |
43 | ||
44 | U_CAPI int32_t U_EXPORT2 | |
45 | u_strToLower(UChar *dest, int32_t destCapacity, | |
46 | const UChar *src, int32_t srcLength, | |
47 | const char *locale, | |
48 | UErrorCode *pErrorCode) { | |
f3c0d7a5 A |
49 | return ustrcase_mapWithOverlap( |
50 | ustrcase_getCaseLocale(locale), 0, UCASEMAP_BREAK_ITERATOR_NULL | |
4388f060 A |
51 | dest, destCapacity, |
52 | src, srcLength, | |
f3c0d7a5 | 53 | ustrcase_internalToLower, *pErrorCode); |
4388f060 A |
54 | } |
55 | ||
56 | U_CAPI int32_t U_EXPORT2 | |
57 | u_strToUpper(UChar *dest, int32_t destCapacity, | |
58 | const UChar *src, int32_t srcLength, | |
59 | const char *locale, | |
60 | UErrorCode *pErrorCode) { | |
f3c0d7a5 A |
61 | return ustrcase_mapWithOverlap( |
62 | ustrcase_getCaseLocale(locale), 0, UCASEMAP_BREAK_ITERATOR_NULL | |
63 | dest, destCapacity, | |
64 | src, srcLength, | |
65 | ustrcase_internalToUpper, *pErrorCode); | |
66 | } | |
67 | ||
68 | U_NAMESPACE_BEGIN | |
69 | ||
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) { | |
75 | return ustrcase_map( | |
76 | ustrcase_getCaseLocale(locale), options, UCASEMAP_BREAK_ITERATOR_NULL | |
77 | dest, destCapacity, | |
78 | src, srcLength, | |
79 | ustrcase_internalToLower, edits, errorCode); | |
80 | } | |
81 | ||
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) { | |
4388f060 | 87 | return ustrcase_map( |
f3c0d7a5 | 88 | ustrcase_getCaseLocale(locale), options, UCASEMAP_BREAK_ITERATOR_NULL |
4388f060 A |
89 | dest, destCapacity, |
90 | src, srcLength, | |
f3c0d7a5 | 91 | ustrcase_internalToUpper, edits, errorCode); |
4388f060 | 92 | } |
f3c0d7a5 A |
93 | |
94 | U_NAMESPACE_END |