1 /* Test character encodings when specified as an argument to openr
2 * when opening a stream to be supplied to batch or batchload.
3 * e.g. S: openr("foo.mac", "CP1252"); batch(S); close(S);
5 * The batch files foo-<encoding>.mac and foo-<encoding>-UTF-8.mac
6 * contain strings which are assigned to the variable foo_string.
7 * All four instances of foo_string (batch and batchload, <encoding> and UTF-8)
10 * foo-<encoding>-UTF-8.mac is the same as foo-<encoding>.mac,
11 * after passing it through a character conversion program
12 * (I think it was iconv but I don't remember for sure).
15 (test_encoding ([ee]) :=
17 if recognized_encoding_p (e)
18 then return (test_encoding_1 (ee[1], e))
19 else printf (true, "rtest_encodings: skip unrecognized encoding ~s~%", e),
20 if %% = done /* all were skipped; pass this test */
23 test_encoding_1 (ee1, e) :=
24 block ([foo_name, foo_UTF8_name],
26 then printf (true, "rtest_encodings: recognized ~s.", e)
27 else printf (true, "rtest_encodings: recognized ~s (an alias of ~s).~%", e, ee1),
28 foo_name: printf (false, "foo-~a.mac", ee1),
29 foo_UTF8_name: printf (false, "foo-~a-UTF-8.mac", ee1),
31 mystream: openr (file_search (foo_name), e),
34 foo_string_1: foo_string,
36 mystream: openr (file_search (foo_name), e),
39 foo_string_2: foo_string,
41 mystream: openr (file_search (foo_UTF8_name), "UTF-8"),
44 foo_string_3: foo_string,
46 mystream: openr (file_search (foo_UTF8_name), "UTF-8"),
49 foo_string_4: foo_string,
50 is (foo_string_2 = foo_string_1
51 and foo_string_3 = foo_string_2
52 and foo_string_4 = foo_string_3)),
56 test_encoding ("CP1252", "WINDOWS-1252");
59 test_encoding ("ISO-8859-1", "ISO8859-1");
62 test_encoding ("ISO-8859-2", "ISO8859-2");
65 test_encoding ("ISO-8859-3", "ISO8859-3");
68 test_encoding ("ISO-8859-4", "ISO8859-4");
71 test_encoding ("ISO-8859-5", "ISO8859-5");
74 test_encoding ("ISO-8859-6", "ISO8859-6");
77 test_encoding ("ISO-8859-7", "ISO8859-7");
80 test_encoding ("ISO-8859-8", "ISO8859-8");
83 test_encoding ("ISO-8859-9", "ISO8859-9");
86 test_encoding ("ISO-8859-10", "ISO8859-10");
89 test_encoding ("ISO-8859-14", "ISO8859-14");
92 test_encoding ("ISO-8859-15", "ISO8859-15");