+ yaz_iconv_t cd = yaz_iconv_open("ISO-8859-1", "MARC8");
+
+ YAZ_CHECK(cd);
+ if (!cd)
+ return;
+
+ YAZ_CHECK(tst_convert(cd, "ax", "ax"));
+
+ /* latin capital letter o with stroke */
+ YAZ_CHECK(tst_convert(cd, "\xa2", "\xd8"));
+
+ /* with latin small letter ae */
+ YAZ_CHECK(tst_convert(cd, "eneb\xb5r", "eneb\346r"));
+
+ YAZ_CHECK(tst_convert(cd, "\xea" "a\xa2", "\xe5" "\xd8"));
+
+ YAZ_CHECK(tst_convert(cd, "\xea" "a\xa2" "b", "\xe5" "\xd8" "b"));
+
+ YAZ_CHECK(tst_convert(cd, "\xea" "a" "\xea" "a", "\xe5" "\xe5"));
+
+ YAZ_CHECK(tst_convert(cd, "Cours de math",
+ "Cours de math"));
+ YAZ_CHECK(tst_convert(cd, "Cours de mathâe",
+ "Cours de mathé"));
+ YAZ_CHECK(tst_convert(cd, "12345678âe",
+ "12345678é"));
+ YAZ_CHECK(tst_convert(cd, "123456789âe",
+ "123456789é"));
+ YAZ_CHECK(tst_convert(cd, "1234567890âe",
+ "1234567890é"));
+ YAZ_CHECK(tst_convert(cd, "12345678901âe",
+ "12345678901é"));
+ YAZ_CHECK(tst_convert(cd, "Cours de mathâem",
+ "Cours de mathém"));
+ YAZ_CHECK(tst_convert(cd, "Cours de mathâematiques",
+ "Cours de mathématiques"));
+
+ yaz_iconv_close(cd);
+}
+
+static void tst_utf8_to_marc8(void)
+{
+ yaz_iconv_t cd = yaz_iconv_open("MARC8", "UTF-8");
+
+ YAZ_CHECK(cd);
+ if (!cd)
+ return;
+
+ YAZ_CHECK(tst_convert(cd, "Cours ", "Cours "));
+
+ /** Pure ASCII. 11 characters (sizeof(outbuf)-1) */
+ YAZ_CHECK(tst_convert(cd, "Cours de mat", "Cours de mat"));
+
+ /** Pure ASCII. 12 characters (sizeof(outbuf)) */
+ YAZ_CHECK(tst_convert(cd, "Cours de math", "Cours de math"));
+
+ /** Pure ASCII. 13 characters (sizeof(outbuf)+1) */
+ YAZ_CHECK(tst_convert(cd, "Cours de math.", "Cours de math."));
+
+ /** UPPERCASE SCANDINAVIAN O */
+ YAZ_CHECK(tst_convert(cd, "S\xc3\x98", "S\xa2"));
+
+ /** ARING */
+ YAZ_CHECK(tst_convert(cd, "A" "\xCC\x8A", "\xEA" "A"));
+
+ /** A MACRON + UMLAUT, DIAERESIS */
+ YAZ_CHECK(tst_convert(cd, "A" "\xCC\x84" "\xCC\x88",
+ "\xE5\xE8\x41"));
+
+ /* Ligature spanning two characters */
+ YAZ_CHECK(tst_convert(cd,
+ "\x74" "\xCD\xA1" "\x73", /* UTF-8 */
+ "\xEB\x74\xEC\x73")); /* MARC-8 */
+
+ /* Double title spanning two characters */
+ YAZ_CHECK(tst_convert(cd,
+ "\x74" "\xCD\xA0" "\x73", /* UTF-8 */
+ "\xFA\x74\xFB\x73")); /* MARC-8 */
+
+ /** Ideographic question mark (Unicode FF1F) */
+ YAZ_CHECK(tst_convert(cd,
+ "\xEF\xBC\x9F" "o", /* UTF-8 */
+ "\033$1" "\x21\x2B\x3B" "\033(B" "o" ));
+
+
+ /** Ideographic space per ANSI Z39.64 */
+ YAZ_CHECK(tst_convert(cd,
+ "\xe3\x80\x80" "o", /* UTF-8 */
+ "\033$1" "\x21\x23\x21" "\033(B" "o" ));
+
+ /** Superscript 0 . bug #642 */
+ YAZ_CHECK(tst_convert(cd,
+ "(\xe2\x81\xb0)", /* UTF-8 */
+ "(\033p0\x1bs)"));
+
+
+ /** bug #1778 */
+ YAZ_CHECK(tst_convert(cd,
+ /* offset 0x530 in UTF-8 rec marccol4.u8.marc */
+ "\xE3\x83\xB3" "\xE3\x82\xBF"
+ "\xCC\x84" "\xCC\x84" "\xE3\x83\xBC" /* UTF-8 */,
+ "\x1B\x24\x31" "\x69\x25\x73"
+ "\x1B\x28\x42" "\xE5\xE5" "\x1B\x24\x31"
+ "\x69\x25\x3F"
+ "\x69\x21\x3C" "\x1B\x28\x42"));
+