X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..a01113dcd0f39d5da295ef82785beff9ed86fe38:/icuSources/i18n/ucsdet.cpp diff --git a/icuSources/i18n/ucsdet.cpp b/icuSources/i18n/ucsdet.cpp index 114f896f..46f69cf9 100644 --- a/icuSources/i18n/ucsdet.cpp +++ b/icuSources/i18n/ucsdet.cpp @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************** - * Copyright (C) 2005-2006, International Business Machines + * Copyright (C) 2005-2016, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************** */ @@ -11,10 +13,15 @@ #include "unicode/ucsdet.h" #include "csdetect.h" #include "csmatch.h" +#include "csrsbcs.h" +#include "csrmbcs.h" +#include "csrutf8.h" +#include "csrucode.h" +#include "csr2022.h" #include "cmemory.h" -#define ARRAY_SIZE(array) (sizeof array / sizeof array[0]) +U_NAMESPACE_USE #define NEW_ARRAY(type,count) (type *) uprv_malloc((count) * sizeof(type)) #define DELETE_ARRAY(array) uprv_free((void *) (array)) @@ -52,14 +59,7 @@ ucsdet_setText(UCharsetDetector *ucsd, const char *textIn, int32_t len, UErrorCo return; } - if (ucsd == NULL) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return; - } - - CharsetDetector *csd = (CharsetDetector *) ucsd; - - csd->setText(textIn, len); + ((CharsetDetector *) ucsd)->setText(textIn, len); } U_CAPI const char * U_EXPORT2 @@ -69,14 +69,7 @@ ucsdet_getName(const UCharsetMatch *ucsm, UErrorCode *status) return NULL; } - if (ucsm == NULL) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return NULL; - } - - CharsetMatch *csm = (CharsetMatch *) ucsm; - - return csm->getName(); + return ((CharsetMatch *) ucsm)->getName(); } U_CAPI int32_t U_EXPORT2 @@ -86,14 +79,7 @@ ucsdet_getConfidence(const UCharsetMatch *ucsm, UErrorCode *status) return 0; } - if (ucsm == NULL) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return 0; - } - - CharsetMatch *csm = (CharsetMatch *) ucsm; - - return csm->getConfidence(); + return ((CharsetMatch *) ucsm)->getConfidence(); } U_CAPI const char * U_EXPORT2 @@ -103,14 +89,7 @@ ucsdet_getLanguage(const UCharsetMatch *ucsm, UErrorCode *status) return NULL; } - if (ucsm == NULL) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return NULL; - } - - CharsetMatch *csm = (CharsetMatch *) ucsm; - - return csm->getLanguage(); + return ((CharsetMatch *) ucsm)->getLanguage(); } U_CAPI const UCharsetMatch * U_EXPORT2 @@ -120,14 +99,7 @@ ucsdet_detect(UCharsetDetector *ucsd, UErrorCode *status) return NULL; } - if (ucsd == NULL) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return NULL; - } - - CharsetDetector *csd = (CharsetDetector *) ucsd; - - return (const UCharsetMatch *) csd->detect(*status); + return (const UCharsetMatch *) ((CharsetDetector *) ucsd)->detect(*status); } U_CAPI void U_EXPORT2 @@ -137,14 +109,7 @@ ucsdet_setDeclaredEncoding(UCharsetDetector *ucsd, const char *encoding, int32_t return; } - if (ucsd == NULL) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return; - } - - CharsetDetector *csd = (CharsetDetector *) ucsd; - - csd->setDeclaredEncoding(encoding,length); + ((CharsetDetector *) ucsd)->setDeclaredEncoding(encoding,length); } U_CAPI const UCharsetMatch** @@ -155,11 +120,6 @@ ucsdet_detectAll(UCharsetDetector *ucsd, return NULL; } - if (ucsd == NULL) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return NULL; - } - CharsetDetector *csd = (CharsetDetector *) ucsd; return (const UCharsetMatch**)csd->detectAll(*maxMatchesFound,*status); @@ -191,9 +151,7 @@ ucsdet_isInputFilterEnabled(const UCharsetDetector *ucsd) return FALSE; } - CharsetDetector *csd = (CharsetDetector *) ucsd; - - return csd->getStripTagsFlag(); + return ((CharsetDetector *) ucsd)->getStripTagsFlag(); } U_CAPI UBool U_EXPORT2 @@ -220,15 +178,28 @@ ucsdet_getUChars(const UCharsetMatch *ucsm, return 0; } - if (ucsm == NULL) { - *status = U_ILLEGAL_ARGUMENT_ERROR; - return 0; - } + return ((CharsetMatch *) ucsm)->getUChars(buf, cap, status); +} + +U_CAPI void U_EXPORT2 +ucsdet_setDetectableCharset(UCharsetDetector *ucsd, const char *encoding, UBool enabled, UErrorCode *status) +{ + ((CharsetDetector *)ucsd)->setDetectableCharset(encoding, enabled, *status); +} - CharsetMatch *csm = (CharsetMatch *) ucsm; - - return csm->getUChars(buf, cap, status); +U_CAPI UEnumeration * U_EXPORT2 +ucsdet_getAllDetectableCharsets(const UCharsetDetector * /*ucsd*/, UErrorCode *status) +{ + return CharsetDetector::getAllDetectableCharsets(*status); +} + +U_DRAFT UEnumeration * U_EXPORT2 +ucsdet_getDetectableCharsets(const UCharsetDetector *ucsd, UErrorCode *status) +{ + return ((CharsetDetector *)ucsd)->getDetectableCharsets(*status); } + U_CDECL_END + #endif