Re: Save files with correct character set



It doesn't work:
    Saving file failed: Invalid byte sequence in conversion input

Using: Glib::file_set_contents(filename, Glib::locale_from_utf8(TextView.get_buffer()->get_text()));

Il 22/03/2012 21:58, Spazzatura.Live ha scritto:

ISO-8859-1 (Latin-1) is not ASCII. It uses the 8th bit for non-ASCII characters. Latin-1 and UTF-8 are ASCII compatible if you stick to the ASCII character set.
I read it after sending the email on Wikipedia...

If you are saving data to file, it is much better to save it in unicode format as UTF-8, and if you need to convert it, convert it when reading. However, if you really think you need to convert to Latin-1, use Glib::convert(). But what drew you to Latin-1? If that is your locale encoding, it won't necessarily be other people's locale encoding, and for that reason saving data to file in the locale encoding is generally a bad idea, as it is non-portable. However, if that is not an issue, you could use Glib::locale_from_utf8(). Chris

I can't, I read it with a Thunderbird extension (not written by me) and I don't know Java very well and should change it on every update... (I told the developer about that, but he didn't seem to understand at all...) When I import this files after opening with Gedit and saving it with character set ISO-8859-15 it works... However, my strings, may contain the Euro's symbol (€) so the ISO-8859-15 should be the right one for saving it correctly, right? (I'm not very experienced about character encoding (as you saw), probably the characters are kind of written just in ISO-8859 and -1/-15 depends on the reader's interpreter)

However, now i just try Glib::locale_from_utf8() and let you know.

Thanks.
Stefano


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