const char* fromcode = "UTF-8";
const char* tocode = "ASCII//TRANSLIT";
- printf("%-60s", "iconv() with //TRANSLIT does not fail...");
+ printf("%-60s", "iconv() //TRANSLIT does not fail...");
if (_my_iconv_open(&cd, tocode, fromcode) == FAILURE) {
printf("ERROR (iconv_open)\n");
return FAILURE;
return SUCCESS;
}
-static int test_nid_drops_untranslatable() {
+/* If iconv() encounters a character in the input buffer that is
+ * valid, but for which an identical character does not exist in the
+ * output codeset [and] if either the //IGNORE or the
+ * //NON_IDENTICAL_DISCARD indicator suffix was specified when the
+ * conversion descriptor cd was opened, the character shall be
+ * discarded but shall still be counted in the return value of the
+ * iconv() call.
+ *
+ * (The above implies that this is not an error condition, since the
+ * return value is -1 for an error.)
+ */
+static int test_iconv_suffix_drops_untranslatable(char* suffix) {
iconv_t cd;
const char* fromcode = "UTF-8";
- const char* tocode = "ASCII//NON_IDENTICAL_DISCARD";
+ char* tocode = malloc(strlen(fromcode) + strlen(suffix) + 1);
+ sprintf(tocode, "ASCII%s", suffix);
+
+ char msg[59];
+ snprintf(msg, 59, "iconv() %s drops untranslatable...", suffix);
+ printf("%-60s", msg);
- printf("%-60s", "iconv() with //NON_IDENTICAL_DISCARD discards...");
if (_my_iconv_open(&cd, tocode, fromcode) == FAILURE) {
printf("ERROR (iconv_open)\n");
return FAILURE;
if (ignore == SUCCESS) {
result |= test_iconv_ignore_ignores_invalid();
- //result |= test_iconv_ignore_ignores_untranslatable();
+ result |= test_iconv_suffix_drops_untranslatable("//IGNORE");
//result |= test_iconv_ignore_does_not_ignore_incomplete_multibyte();
}
}
if (non_identical_discard == SUCCESS) {
- result |= test_nid_drops_untranslatable();
+ result |= test_iconv_suffix_drops_untranslatable("//NON_IDENTICAL_DISCARD");
//result |= test_nid_fails_on_incomplete_multibyte();
}