Re: a problem about the charset convert functions



On 6/23/05, 顺珉 吴 <moody_blur yahoo com cn> wrote:

There are two types of convert functions:
the g_locale_to(from)_utf8 and the
g_filename_to(from)_utf8().

The first says it "Converts a string which is in the
encoding used for strings by the C runtime (usually
the same as that used by the operating system) in the
current locale into a UTF-8 string."

And the laster says it"Converts a string which is in
the encoding used by GLib for filenames into a UTF-8
string."

So, what is the different between "C runtime" string
and "GLib" string? Which should be used on which
situation?


I don't think this is the difference between the two functions. There are no 
differences between them, they are all char*, if I understand correctly
In my opinion, g_filename_to_utf8 would check the environment variable 
G_FILENAME_ENCODING, while g_locale_to_utf8 would check LC_*s and LANG

If you are getting a filename from filechooser, you must convert it to the 
local file system encoding with g_filename_from_utf8, and reading a 
directory with readdir and then display it with gtk, you should convert it 
to utf8 with g_filename_to_utf8.

If you are getting input from user and display it, you should convert it to 
UTF8 with g_locale_to_utf8()

Thanks.




-- 
Best regards

Shixin Zeng


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