Re: [gtkmm] UTF8 filenames? (Was One thing we didn't really discuss: ustring vs string)



Sebastian Rittau wrote:
On Mon, Aug 12, 2002 at 06:14:21PM +0100, Murray Cumming wrote:


But this, from ChangeLog suggests that Daniel knew what he was doing:

2002-06-15  Daniel Elstner  <daniel elstner gmx net>

	* gtk/src/fileselection.hg (set_filename): Change the filename
	argument type to std::string.  The get_filename/set_filename
	inconsistency has been fixed in GTK+ 2.0.4.


Maybe I can explain a bit, since I was the one that did originally
submit that bug report to gtk+. Normally all gtk+ passed to and from
gtk+ are UTF-8 encoded. This is not true for the [gs]et_filename methods
of GtkFileSelection. These expect the filename in the filename encoding
(i.e. in this case the same encoding the open() call expects), which is
then internally tranformed to UTF-8. (This was broken in versions prior
to 2.0.5.)

So, at least if you don't plan to do the filename encoding <-> UTF-8
conversion yourself (which I would recommend against[1]), you have to
use an all-purpose string as argument/return value to [gs]et_filename.
Filenames can be in any encoding, including UTF-8.

 - Sebastian

[1] For convenience reasons. This way you can simply write stuff like:

      filename = dialog->get_filename ();
      fd = open (filename);

    Otherwise you'd had to convert filename first.

Right, but to be clear, if you wanted to use filename in Gtk, such as in a Label or Entry, you _would_ want to convert it to UTF8 to support multilingual text, correct? Likewise, if you have an Entry where the user can type a filename, you should convert that from UTF8 before calling open on it, correct?


--
Michael Babcock
Jim Henson's Creature Shop





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