Re: how to set language for non-unicode text



On Mon, Dec 28, 2009 at 11:33 PM, Tor Lillqvist <tml iki fi> wrote:
I wrote my first linux GUI app using GTK+, which seems to be a very
nice tool.

Well, GTK+ is not a "tool" but a library, also called a "tooolkit", so
I wonder whether what you actually have been using some higher level
GUI application or "toolt" to write code that uses GTK+? Anyway, let's
assume that was just an accidental use of the wrong word.

I just use GTK+ library directly, not a higher level tool/wrapper..


 One question I had is: how can I set the language for non-unicode text in my application?

That question doesn't really make sense, as

1) GTK+ accepts only Unicode text (in particular, encoded as UTF-8)

2) Even if text is in Unicode it needs language-dependeng handling
(especially for text in Chinese, Japanese or Korean, where
language-specific fonts should be used even if the code points for the
ideographs are unified). Anyway, as such it isn't really GTK+ that
needs to know the language of some text, but Pango. (Another library,
that GTK+ uses to layout text.) See for instance
http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html .

Thanks for the pointer. As dumb as it sounds, I am still confused
about relations between Pango and GTK+.  (For example, does GTK+
application come with Pango by default? do I need to include Pango
explicitly? Do I have to use Pango markup language in order to process
CJK text in GTK+?)


 I tried to use iconv(), but did not work out. The iconv_open call returned error ENOENT (2).  Not sure
if i am in the correct direction.

Well, if you suspect that iconv() is what you need, then probably
indeed it is. How to use iconv() is not really a GTK+ question, you
just need to read its documentation carefully. Note that iconv() is
not related to *languages* as such, but codesets and encodings. (But
yeah, many codesets and encodings are specifically used for one
language in one country, or a closely related group of languages.)
Also note that GLib has a convenience API on top of iconv() to make it
a bit friendlier to use, see
http://library.gnome.org/devel/glib/stable/glib-Character-Set-Conversion.html
.

I suspect you need to give us more details of what your problem
actually is. Where do the strings come from that you tried to use
iconv() on? Do you know what language they are? Do you know what
codeset and encoding they are? What do you need to do with them?

I am building a GTK+ app that reads MP3 songs among other things. It
extracts and displays song names that embedded in the MP3 files. These
song names could be in English or Chinese.  For Chinese song names,
they are encoded in GB2312 and stored in the MP3 files.  Let me read
Glib API.  Thanks for the pointer.

Han


--tml




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