Re: Pango warning: "Invalid UTF-8 string"



Been on vacation,

Matthias Kaeppler <nospam digitalraid com> writes:

> Murray Cumming wrote:
>> If you are getting the filename from the FileChooser, the "Note:" here
>> might be helpful:
>> http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1FileChooser.html
>> std::string -> ustring involves an automatic encoding conversion, so
>> that might be confusing things.
>
> Hm, no, the std::stringS come from Gnome::Vfs::FileInfo::get_name().
> Converting them to a ustring using filename_to_utf8() does, well, 
> nothing. Most surprisingly locale_to_utf8() works in this case.

Your system is probably inappropriately configured. From the link
Murray provided:

  When the user is finished selecting files in a FileChooser, your
  program can get the selected names either as filenames or as URIs.
  [...] However, filenames are always returned in the character set
  specified by the G_FILENAME_ENCODING environment variable. Please
  see the Glib documentation for more details about this variable.

Then
  
  http://developer.gnome.org/doc/API/2.0/glib/glib-Character-Set-Conversion.html#g-filename-to-utf8

has the scoop

  [...] By default, Glib assumes that file names on disk are in UTF-8
  encoding. This is a valid assumption for file systems which were
  created relatively recently: most applications use UTF-8 encoding
  for their strings, and that is also what they use for the file
  names they create. However, older file systems may still contain
  file names created in "older" encodings, such as ISO-8859-1. In
  this case, for compatibility reasons, you may want to instruct Glib
  to use that particular encoding for file names rather than UTF-8.
  You can do this by specifying the encoding for file names in the
  G_FILENAME_ENCODING environment variable. [...] 

Either use LANG=blabla.UTF-8 or set G_FILENAME_ENCODING.

-- 
Ole Laursen
http://www.cs.aau.dk/~olau/



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