Bruno Haible wrote on 2000-10-30 19:31 UTC:
> Robert Brady writes:
>
> > How does it implement the following :
> >
> > wchar_t *foo = "\u00A0";
> >
> > int main() {
> > setlocale(LC_ALL, "");
> > wprintf(foo);
> > }
>
> As equivalent of
>
> int main() {
> setlocale(LC_ALL, "");
> printf("\xA0");
> }
>
> Both of these programs will only work in particular locales
> (ISO-8859-1 or so).
Robert's version is supposed to output NBSP correctly in any locale that
supports this character (for example NBSP in CP850 is 0xff), while your
second version is always outputting the byte 0xa0. If that is what
FreeBSD is doing, that is rather disappointing.
> To print messages that are correct in all languages, one needs
> gettext().
But gettext is overkill for monolingual applications that want to run in
different character encodings (and there are *many* of these). I do not
want to have to be forced to use (the non-standard!) gettext in an
English application, just to get the nicest possible double quotation
marks in all of ISO 8859-1, CP1252 and UTF-8 locales. I just want to
write in maximally portable ISO C99 code
#if __STDC_ISO_10646__
printf("%lc", 0x201c);
#else
putchar('"');
#fi
and it should do the right thing depending on the locale (including
transliteration to " for ISO 8859-1, which glibc 2.1.96 fails to do at
the moment unfortunately).
Markus
--
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org, WWW: <http://www.cl.cam.ac.uk/~mgk25/>
-
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/lists/