On Fri, Nov 12, 2004 at 03:00:43PM -0500, Edward H. Trager wrote:

Hi,

> void écrire(const char *myCString);   // Function name has Latin-1 chars *in 
> UTF-8 encoding*

No... I only want to use non-ascii (perhaps latin-2 but preferably utf-8)
characters inside string constants, or maybe for comments, but the later one
is not interesting.

> 2. Although the strings in your program can be in any encoding you want, 
> UTF-8 certainly makes
>    the most sense.

If I use UTF-8 with plain printf("%s", "...") then I have to manually
convert them to the actual locale if that one differs from UTF-8. Or I have
to use gettext which automatically does this conversion for me.

Though I haven't really heard about the printf("%ls, L"...") feature before,
now I've found it in Markus's faq and thought this was what I need. In this
case, if you look at the compiled binary, the string is stored in UCS-4
instead of UTF-8 which doesn't matter as long as there aren't too much of
these strings. And then "%ls" automagically converts this into the current
locale. The problem with this solution is, however, that conversion does not
only happen at runtime but also at compile time, I have to tell to gcc what
encoding I used in the L"..." string, otherwise it fails to properly convert
it to UCS-4. Unfortunately, as Bruno showed me, this feature is only
available from gcc 3.4 and isn't really portable. So for gcc 3.3 only two
choices remain: either use gettext or manually iconv the strings.



bye,

Egmont

--
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/

Reply via email to