+// © 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.
********************************************************************************
*/
#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))
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
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
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
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
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
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**
return NULL;
}
- if (ucsd == NULL) {
- *status = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
- }
-
CharsetDetector *csd = (CharsetDetector *) ucsd;
return (const UCharsetMatch**)csd->detectAll(*maxMatchesFound,*status);
return FALSE;
}
- CharsetDetector *csd = (CharsetDetector *) ucsd;
-
- return csd->getStripTagsFlag();
+ return ((CharsetDetector *) ucsd)->getStripTagsFlag();
}
U_CAPI UBool U_EXPORT2
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