~ubuntu-branches/ubuntu/maverick/icu/maverick-updates

« back to all changes in this revision

Viewing changes to source/i18n/csmatch.cpp

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2009-09-04 11:56:06 UTC
  • mfrom: (10.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20090904115606-sqxxuizelam5tozb
Tags: 4.2.1-3
Change install-doc target to not fail if there are subdirectories of
doc/html.  This is necessary to handle the doc/html/search directory
created by doxygen 3.6.1.  (Closes: #544799)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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) const
 
50
{
 
51
    UConverter *conv = ucnv_open(getName(), status);
 
52
    int32_t result = ucnv_toUChars(conv, buf, cap, (const char *) textIn->fRawInput, textIn->fRawLength, status);
 
53
 
 
54
    ucnv_close(conv);
 
55
 
 
56
    return result;
 
57
}
 
58
 
 
59
U_NAMESPACE_END
 
60
 
 
61
#endif