Coverage Report

Created: 2025-06-24 06:43

/src/icu/source/common/ustrcase_locale.cpp
Line
Count
Source (jump to first uncovered line)
1
// © 2016 and later: Unicode, Inc. and others.
2
// License & terms of use: http://www.unicode.org/copyright.html
3
/*
4
*******************************************************************************
5
*   Copyright (C) 2011, International Business Machines
6
*   Corporation and others.  All Rights Reserved.
7
*******************************************************************************
8
*   file name:  ustrcase_locale.cpp
9
*   encoding:   UTF-8
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"
21
#include "uassert.h"
22
#include "unicode/brkiter.h"
23
#include "unicode/casemap.h"
24
#include "unicode/ucasemap.h"
25
#include "unicode/uloc.h"
26
#include "unicode/ustring.h"
27
#include "ucase.h"
28
#include "ucasemap_imp.h"
29
30
U_CFUNC int32_t
31
0
ustrcase_getCaseLocale(const char *locale) {
32
0
    if (locale == NULL) {
33
0
        locale = uloc_getDefault();
34
0
    }
35
0
    if (*locale == 0) {
36
0
        return UCASE_LOC_ROOT;
37
0
    } else {
38
0
        return ucase_getCaseLocale(locale);
39
0
    }
40
0
}
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
0
             UErrorCode *pErrorCode) {
49
0
    return ustrcase_mapWithOverlap(
50
0
        ustrcase_getCaseLocale(locale), 0, UCASEMAP_BREAK_ITERATOR_NULL
51
0
        dest, destCapacity,
52
0
        src, srcLength,
53
0
        ustrcase_internalToLower, *pErrorCode);
54
0
}
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
0
             UErrorCode *pErrorCode) {
61
0
    return ustrcase_mapWithOverlap(
62
0
        ustrcase_getCaseLocale(locale), 0, UCASEMAP_BREAK_ITERATOR_NULL
63
0
        dest, destCapacity,
64
0
        src, srcLength,
65
0
        ustrcase_internalToUpper, *pErrorCode);
66
0
}
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
0
        UErrorCode &errorCode) {
75
0
    return ustrcase_map(
76
0
        ustrcase_getCaseLocale(locale), options, UCASEMAP_BREAK_ITERATOR_NULL
77
0
        dest, destCapacity,
78
0
        src, srcLength,
79
0
        ustrcase_internalToLower, edits, errorCode);
80
0
}
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
0
        UErrorCode &errorCode) {
87
0
    return ustrcase_map(
88
0
        ustrcase_getCaseLocale(locale), options, UCASEMAP_BREAK_ITERATOR_NULL
89
0
        dest, destCapacity,
90
0
        src, srcLength,
91
0
        ustrcase_internalToUpper, edits, errorCode);
92
0
}
93
94
U_NAMESPACE_END