+
+static void tst_utf8_to_marc8()
+{
+ 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)) */
+ 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" ));
+
+ yaz_iconv_close(cd);
+}
+
+
+static void tst_latin1_to_marc8()
+{
+ yaz_iconv_t cd = yaz_iconv_open("MARC8", "ISO-8859-1");
+
+ 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)) */
+ YAZ_CHECK(tst_convert(cd, "Cours de math.", "Cours de math."));
+
+ /** D8: UPPERCASE SCANDINAVIAN O */
+ YAZ_CHECK(tst_convert(cd, "S\xd8", "S\xa2"));
+
+ /** E9: LATIN SMALL LETTER E WITH ACUTE */
+ YAZ_CHECK(tst_convert(cd, "Cours de math\xe9", "Cours de mathâe"));
+ YAZ_CHECK(tst_convert(cd, "Cours de math", "Cours de math"
+ ));
+ YAZ_CHECK(tst_convert(cd, "Cours de mathé", "Cours de mathâe" ));
+ YAZ_CHECK(tst_convert(cd, "12345678é","12345678âe"));
+ YAZ_CHECK(tst_convert(cd, "123456789é", "123456789âe"));
+ YAZ_CHECK(tst_convert(cd, "1234567890é","1234567890âe"));
+ YAZ_CHECK(tst_convert(cd, "12345678901é", "12345678901âe"));
+ YAZ_CHECK(tst_convert(cd, "Cours de mathém", "Cours de mathâem"));
+ YAZ_CHECK(tst_convert(cd, "Cours de mathématiques",
+ "Cours de mathâematiques"));
+ yaz_iconv_close(cd);
+}
+
+static void tst_utf8_codes()
+{
+ YAZ_CHECK(utf8_check(3));
+ YAZ_CHECK(utf8_check(127));
+ YAZ_CHECK(utf8_check(128));
+ YAZ_CHECK(utf8_check(255));
+ YAZ_CHECK(utf8_check(256));
+ YAZ_CHECK(utf8_check(900));
+ YAZ_CHECK(utf8_check(1000));
+ YAZ_CHECK(utf8_check(10000));
+ YAZ_CHECK(utf8_check(100000));
+ YAZ_CHECK(utf8_check(1000000));
+ YAZ_CHECK(utf8_check(10000000));
+ YAZ_CHECK(utf8_check(100000000));
+}
+