Re: OFF-TOPIC: Converting latin-1 to unicode



Hello!

>   I need to convert a string in whatever encoding used by the system (I
> use latin-1) to unicode. I need it to render strings with freetype -- the
> font I'm using uses unicode encoding. 
> 
>   I looked at iconv, but it seems to convert only between different
> multibyte encodings. I also looked at libunicode, but couldn't find the
> function I need.

If you want (bad idea!) hardcode iso-8859-1 (latin1) into your app,
you do not need any transcoding. Just:

(gint) unival = (guchar) character
does the conversion

Otherwise use iconv_open and iconv. They transcode between encodings
with whatever char sizes, including variable ones (UTF-8). There
are equivalent ones in libunicode, but the latter will be deprecated
after gnome-1.4.
If are not afraid of libraries, you can also look into gal (Gnome
Applications Library). There are pre-2.0 convenience functions for
converting between encoding used by given Gtk+ widget font, and UTF-8.
>From latter you can extract unicode values.

Lauris






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]