]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/csmatch.cpp
2 **********************************************************************
3 * Copyright (C) 2005-2012, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
8 #include "unicode/utypes.h"
10 #if !UCONFIG_NO_CONVERSION
11 #include "unicode/unistr.h"
12 #include "unicode/ucnv.h"
21 CharsetMatch::CharsetMatch()
22 : textIn(NULL
), confidence(0), fCharsetName(NULL
), fLang(NULL
)
24 // nothing else to do.
27 void CharsetMatch::set(InputText
*input
, const CharsetRecognizer
*cr
, int32_t conf
,
28 const char *csName
, const char *lang
)
32 fCharsetName
= csName
;
35 if (fCharsetName
== NULL
) {
36 fCharsetName
= cr
->getName();
39 fLang
= cr
->getLanguage();
44 const char* CharsetMatch::getName()const
49 const char* CharsetMatch::getLanguage()const
54 int32_t CharsetMatch::getConfidence()const
59 int32_t CharsetMatch::getUChars(UChar
*buf
, int32_t cap
, UErrorCode
*status
) const
61 UConverter
*conv
= ucnv_open(getName(), status
);
62 int32_t result
= ucnv_toUChars(conv
, buf
, cap
, (const char *) textIn
->fRawInput
, textIn
->fRawLength
, status
);