}
for (idx = 0; idx < UPRV_LENGTHOF(testStrings); idx++) {
+ status = U_ZERO_ERROR;
ucsdet_setText(csd, testStrings[idx], -1, &status);
match = ucsdet_detect(csd, &status);
if (exec) Ticket6954Test();
break;
+ case 10: name = "Ticket21823Test";
+ if (exec) Ticket21823Test();
+ break;
+
default: name = "";
break; //needed to end loop
}
TEST_ASSERT(strcmp(name1, "windows-1252")==0);
#endif
}
+
+
+// Ticket 21823 - Issue with Charset Detector for ill-formed input strings.
+// Its fix involves returning a failure based error code
+// (U_INVALID_CHAR_FOUND) incase no charsets appear to match the input data.
+void CharsetDetectionTest::Ticket21823Test() {
+ UErrorCode status = U_ZERO_ERROR;
+ std::string str = "\x80";
+ UCharsetDetector* csd = ucsdet_open(&status);
+
+ ucsdet_setText(csd, str.data(), str.length(), &status);
+ const UCharsetMatch* match = ucsdet_detect(csd, &status);
+
+ if (match == NULL) {
+ TEST_ASSERT(U_FAILURE(status));
+ }
+
+ ucsdet_close(csd);
+}
virtual void IBM420Test();
virtual void Ticket6394Test();
virtual void Ticket6954Test();
+ virtual void Ticket21823Test();
private:
void checkEncoding(const UnicodeString &testString,