1 AT_BANNER([i18n routines])
3 # CHECK_I18N([TITLE], [FROM-CODING], [TO-CODING], [FROM-TEXT], [TO-TEXT])
5 # Converts FROM-TEXT from FROM-CODING to TO-CODING and checks that the result
6 # is TO-TEXT. The "printf" program is applied to both FROM-TEXT and TO-TEXT
7 # to allow for backslash-escapes. (Be aware that hex escapes are not portable;
8 # use octal escapes instead.)
9 m4_define([CHECK_I18N],
10 [AT_SETUP([convert $1])
13 dnl Skip the test if this host doesn't know the source and target encodings.
16 *-*-linux* | *-*-*-gnu*)
17 dnl GNU/Linux always has the encodings we want. We can't ask
18 dnl config.charset about them because it has a special case here
19 dnl too and won't tell us.
22 $SHELL $top_srcdir/gl/config.charset "$host" | grep '$2' || exit 77
23 $SHELL $top_srcdir/gl/config.charset "$host" | grep '$3' || exit 77
27 AT_CHECK_UNQUOTED([i18n-test '$2' '$3' `printf '$4'`], [0], [`printf '$5'`
31 CHECK_I18N([reflexively], [ASCII], [ASCII], [abc], [abc])
32 CHECK_I18N([without any change], [ASCII], [UTF-8], [abc], [abc])
34 CHECK_I18N([from ISO-8859-1 to UTF-8], [ISO-8859-1], [UTF-8],
36 CHECK_I18N([from UTF-8 to ISO-8859-1], [UTF-8], [ISO-8859-1],
39 # 0xc0 == 0300 is invalid in UTF-8
40 CHECK_I18N([invalid UTF-8 to ISO-8859-1], [UTF-8], [ISO-8859-1],
42 # 0xc2 == 0302 is the first byte of a 2-byte UTF-8 sequence
43 CHECK_I18N([truncated UTF-8 to ISO-8559-1], [UTF-8], [ISO-8859-1],
46 dnl The input to this test is 7 bytes long and the expected output is 9 bytes.
47 dnl So it should exercise the E2BIG case
48 CHECK_I18N([from ISO-8859-1 to UTF-8 with overflow], [ISO-8859-1], [UTF-8],
49 [Tsch\374\337!], [Tsch\303\274\303\237!])