OLD | NEW |
(Empty) | |
| 1 /* |
| 2 ********************************************************************** |
| 3 * Copyright (C) 2005-2006, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. |
| 5 ********************************************************************** |
| 6 */ |
| 7 |
| 8 #include "unicode/utypes.h" |
| 9 |
| 10 #if !UCONFIG_NO_CONVERSION |
| 11 #include "unicode/unistr.h" |
| 12 #include "unicode/ucnv.h" |
| 13 |
| 14 #include "csmatch.h" |
| 15 |
| 16 #include "csrecog.h" |
| 17 #include "inputext.h" |
| 18 |
| 19 U_NAMESPACE_BEGIN |
| 20 |
| 21 CharsetMatch::CharsetMatch() |
| 22 : csr(0), confidence(0) |
| 23 { |
| 24 // nothing else to do. |
| 25 } |
| 26 |
| 27 void CharsetMatch::set(InputText *input, CharsetRecognizer *cr, int32_t conf) |
| 28 { |
| 29 textIn = input; |
| 30 csr = cr; |
| 31 confidence = conf; |
| 32 } |
| 33 |
| 34 const char* CharsetMatch::getName()const |
| 35 { |
| 36 return csr->getName(); |
| 37 } |
| 38 |
| 39 const char* CharsetMatch::getLanguage()const |
| 40 { |
| 41 return csr->getLanguage(); |
| 42 } |
| 43 |
| 44 int32_t CharsetMatch::getConfidence()const |
| 45 { |
| 46 return confidence; |
| 47 } |
| 48 |
| 49 int32_t CharsetMatch::getUChars(UChar *buf, int32_t cap, UErrorCode *status) con
st |
| 50 { |
| 51 UConverter *conv = ucnv_open(getName(), status); |
| 52 int32_t result = ucnv_toUChars(conv, buf, cap, (const char *) textIn->fRawIn
put, textIn->fRawLength, status); |
| 53 |
| 54 ucnv_close(conv); |
| 55 |
| 56 return result; |
| 57 } |
| 58 |
| 59 U_NAMESPACE_END |
| 60 |
| 61 #endif |
OLD | NEW |