1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (C) 2005-2012, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
10 #include "unicode/utypes.h"
12 #if !UCONFIG_NO_CONVERSION
13 #include "unicode/unistr.h"
14 #include "unicode/ucnv.h"
23 CharsetMatch::CharsetMatch()
24 : textIn(NULL
), confidence(0), fCharsetName(NULL
), fLang(NULL
)
26 // nothing else to do.
29 void CharsetMatch::set(InputText
*input
, const CharsetRecognizer
*cr
, int32_t conf
,
30 const char *csName
, const char *lang
)
34 fCharsetName
= csName
;
37 if (fCharsetName
== NULL
) {
38 fCharsetName
= cr
->getName();
41 fLang
= cr
->getLanguage();
46 const char* CharsetMatch::getName()const
51 const char* CharsetMatch::getLanguage()const
56 int32_t CharsetMatch::getConfidence()const
61 int32_t CharsetMatch::getUChars(UChar
*buf
, int32_t cap
, UErrorCode
*status
) const
63 UConverter
*conv
= ucnv_open(getName(), status
);
64 int32_t result
= ucnv_toUChars(conv
, buf
, cap
, (const char *) textIn
->fRawInput
, textIn
->fRawLength
, status
);