/* Preparations: - Install locale named 'de_DE.UTF-8' (using localedef). - Find attached mail.po - $ mkdir -p de/LC_MESSAGES $ msgfmt -c -o de/LC_MESSAGES/mail.mo mail.po or $ msgfmt -c -o de/LC_MESSAGES/mail.mo mail-utf8.po - $ gcc -Wall foo.c - $ LC_ALL=de_DE.UTF-8 ./a.out */ #include #include #include int main () { if (setlocale (LC_ALL, "") == NULL) return 1; textdomain ("mail"); bindtextdomain ("mail", "."); unsigned int n_recipients; n_recipients = 1; // The following outputs "1 Empfänger" encoded in UTF-8: printf("%s\n", ngettext("recipient", "recipients", n_recipients)); bind_textdomain_codeset("mail", "ASCII"); n_recipients = 1; // The following outputs "recipient" with the same encoding as the "recipient" // argument to ngettext (remember, the the system is assumed to not support // conversion from ISO/IEC 8859-1 to ASCII): printf("%s\n", ngettext("recipient", "recipients", n_recipients)); // On GNU gettext, "1 Empfänger" is output in ISO-8859-1 here (i.e. no conversion is done). I think we already agreed on considering this behavior a bug, } /* With a mail.po that contains only umlauts: Output on glibc systems (e.g. 2.32): 1 Empfänger 1 Empfaenger Output on non-glibc systems with GNU libiconv: 1 Empfänger 1 Empf"anger With a mail-utf8.po that contains also Hanzi characters: Output on glibc systems (e.g. 2.32): 1 Empfänger Chinese (中文,普通话,汉语) 你好 1 Empfaenger Chinese (??,???,??) ?? Output on non-glibc systems with GNU libiconv: 1 Empfänger Chinese (中文,普通话,汉语) 你好 recipient */