[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using utf-8 in an application
Hi there,
I am one of the main developers creating a new standard for cross-platform
video effects.
http://livido.dyne.org
In the standard we define various property types, including a STRING type.
We decided to use utf-8 as the encoding for strings.
I have a couple of quick questions, perhaps somebody could give me some
quick answers :-)
The reference implementation is here:
http://livido.dyne.org/trac.cgi/wiki/RefLivido.h
http://livido.dyne.org/trac.cgi/wiki/RefLivido.c
Here are the questions.
1) In livido.h we #include <wchar.c>
is this the right header for dealing with utf-8 ? 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.
2) for getting the utf-8 string length in bytes, we use wcslen(). Is this
the correct function ?
3) when a string is retrieved, we must add a utf-8 terminating NULL to the
end. How is this done ?
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 ?
The basic flow of the test is:
create a char *string, convert it to utf-8 in the test app.
call the set_property() function. This stores the n bytes (without NULL)
of the string.
call the get_property() function, this should copy the n bytes and add a
terminating utf-8 NULL.
convert the result back to ASCII char *, and print out the resulting
retrieved string on the terminal.
Any help would be appreciated.
Perhaps you could also check our livido.c for utf-8 correctness.
Regards,
Gabriel.
livido developer (http://livido.dyne.org)
main developer, the LiVES Project (http://lives.sf.net)
--
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/linux-utf8/