> Here are the questions.
>
> 1) In livido.h we #include <wchar.c>
>
> is this the right header for dealing with utf-8 ?
No. Wide characters are useless, because they differ in width and in
representation between platforms. On some platforms, wide character values
are even locale dependent.
> We want to keep the
> header file as light as possible, so it would be preferable to include as
> little code as possible. The only functions we need are to get a string
> length in bytes, so it can be stored, and then to add a terminating utf-8
> NULL when the string is retrieved, since NULL is not stored.
strlen() will do it.
> 2) for getting the utf-8 string length in bytes, we use wcslen(). Is this
> the correct function ?
No, use strlen().
> 3) when a string is retrieved, we must add a utf-8 terminating NULL to the
> end. How is this done ?
Like you add an ASCII '\0' to an 8-bit string.
> 4) For testing purposes, I want to create a utf-8 string. Is there a
> simple way to convert a char *string to utf-8 ?
A "char *" is normally in locale dependent encoding. To convert it to
UTF-8, you need to go through iconv(). Look for example
- at function u8_conv_from_locale() in
libuniconv/localeconv.c
libuniconv/uniconv.c
in ftp://ftp.ilog.fr/pub/Users/haible/gnu/libunistring-0.0.tar.gz
- or the extras/iconv_string.c in libiconv-1.10.tar.gz,
- or the 'iconvme' module in gnulib (http://savannah.gnu.org/projects/gnulib)
Bruno
--
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/linux-utf8/