/*
**********************************************************************
- * Copyright (C) 2005-2006, International Business Machines
+ * Copyright (C) 2005-2012, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
#if !UCONFIG_NO_CONVERSION
#include "csrucode.h"
+#include "csmatch.h"
U_NAMESPACE_BEGIN
return "UTF-16BE";
}
-int32_t CharsetRecog_UTF_16_BE::match(InputText* textIn)
+UBool CharsetRecog_UTF_16_BE::match(InputText* textIn, CharsetMatch *results) const
{
const uint8_t *input = textIn->fRawInput;
+ int32_t confidence = 0;
if (input[0] == 0xFE && input[1] == 0xFF) {
- return 100;
+ confidence = 100;
}
// TODO: Do some statastics to check for unsigned UTF-16BE
- return 0;
+ results->set(textIn, this, confidence);
+ return (confidence > 0);
}
CharsetRecog_UTF_16_LE::~CharsetRecog_UTF_16_LE()
return "UTF-16LE";
}
-int32_t CharsetRecog_UTF_16_LE::match(InputText* textIn)
+UBool CharsetRecog_UTF_16_LE::match(InputText* textIn, CharsetMatch *results) const
{
const uint8_t *input = textIn->fRawInput;
+ int32_t confidence = 0;
if (input[0] == 0xFF && input[1] == 0xFE && (input[2] != 0x00 || input[3] != 0x00)) {
- return 100;
+ confidence = 100;
}
// TODO: Do some statastics to check for unsigned UTF-16LE
- return 0;
+ results->set(textIn, this, confidence);
+ return (confidence > 0);
}
CharsetRecog_UTF_32::~CharsetRecog_UTF_32()
// nothing to do
}
-int32_t CharsetRecog_UTF_32::match(InputText* textIn)
+UBool CharsetRecog_UTF_32::match(InputText* textIn, CharsetMatch *results) const
{
const uint8_t *input = textIn->fRawInput;
int32_t limit = (textIn->fRawLength / 4) * 4;
confidence = 25;
}
- return confidence;
+ results->set(textIn, this, confidence);
+ return (confidence > 0);
}
CharsetRecog_UTF_32_BE::~CharsetRecog_UTF_32_BE()