Coverage Report

Created: 2026-06-13 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/icu/source/i18n/csmatch.cpp
Line
Count
Source
1
// © 2016 and later: Unicode, Inc. and others.
2
// License & terms of use: http://www.unicode.org/copyright.html
3
/*
4
 **********************************************************************
5
 *   Copyright (C) 2005-2012, International Business Machines
6
 *   Corporation and others.  All Rights Reserved.
7
 **********************************************************************
8
 */
9
10
#include "unicode/utypes.h"
11
12
#if !UCONFIG_NO_CONVERSION
13
#include "unicode/unistr.h"
14
#include "unicode/ucnv.h"
15
16
#include "csmatch.h"
17
18
#include "csrecog.h"
19
#include "inputext.h"
20
21
U_NAMESPACE_BEGIN
22
23
CharsetMatch::CharsetMatch()
24
18.4M
  : textIn(nullptr), confidence(0), fCharsetName(nullptr), fLang(nullptr)
25
18.4M
{
26
    // nothing else to do.
27
18.4M
}
28
29
void CharsetMatch::set(InputText *input, const CharsetRecognizer *cr, int32_t conf,
30
                       const char *csName, const char *lang)
31
18.5M
{
32
18.5M
    textIn = input;
33
18.5M
    confidence = conf; 
34
18.5M
    fCharsetName = csName;
35
18.5M
    fLang = lang;
36
18.5M
    if (cr != nullptr) {
37
18.5M
        if (fCharsetName == nullptr) {
38
14.5M
            fCharsetName = cr->getName();
39
14.5M
        }
40
18.5M
        if (fLang == nullptr) {
41
14.5M
            fLang = cr->getLanguage();
42
14.5M
        }
43
18.5M
    }
44
18.5M
}
45
46
const char* CharsetMatch::getName()const
47
673k
{
48
673k
    return fCharsetName; 
49
673k
}
50
51
const char* CharsetMatch::getLanguage()const
52
0
{
53
0
    return fLang; 
54
0
}
55
56
int32_t CharsetMatch::getConfidence()const
57
4.30M
{
58
4.30M
    return confidence;
59
4.30M
}
60
61
int32_t CharsetMatch::getUChars(char16_t *buf, int32_t cap, UErrorCode *status) const
62
0
{
63
0
    UConverter *conv = ucnv_open(getName(), status);
64
0
    int32_t result = ucnv_toUChars(conv, buf, cap, reinterpret_cast<const char*>(textIn->fRawInput), textIn->fRawLength, status);
65
66
0
    ucnv_close(conv);
67
68
0
    return result;
69
0
}
70
71
U_NAMESPACE_END
72
73
#endif