[vlc-devel] UTF-8 support
courmisch at via.ecp.fr
Thu Aug 4 16:41:07 CEST 2005
r11988 introduces 4 new APIs :
FromLocale() takes a C string in OS locale's charset and returns a C
string in UTF-8. Invalid character sequences are replaced with question
marks (that should obviously never happen if the locale is
ToLocale() takes a C string in UTF-8 and returns a C string in locale's
charset. Invalid character sequences are replaced with question marks;
if that happens, a FromLocale() or EnsureUTF8() call is probably
LocaleFree() frees memory allocated by FromLocale() or ToLocale().
It should be noted that all of these are no-ops if the locale is UTF-8.
DO NOT assume that LocaleFree() is free(), otherwise you'll crash if
the locale is UTF-8. DO NOT assume that LocaleFree() is no-op otherwise
you'll leak memory if the locale is not UTF-8.
Finally, EnsureUTF8() replaces all invalid characters sequences in a
supposedly UTF-8 string with question marks. It should be used when a
string is supposed to be UTF-8 encoded, but needs sanity checking (e.g.
obtained from a file, from the network, etc). It should be called
before passing the string to some other VLC components.
The idea now is that every string that is potentially passed among
different plugins/components should be UTF-8 encoded.
In particular, putting a non-UTF8 character string in some psz_whatever
parameter of a public structure is now to be considered a bug. It
should also be assumed that every thing in the playlist is UTF8
* optimize the APIs,
* add lots of EnsureUTF8() where appropriate
* all interface plugins that need to work in the user's locale should be
reviewed and (From|To)Locale() should be used as appropriate.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the vlc-devel