Re: UTF-8 error in GtkTextView while decoding base64

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

 



On Mon, Apr 14, 2014 at 02:22:00PM -0400, a wrote:
>     const Glib::ustring str = Glib::Base64::decode("YmJi3A==");

YmJi3A== represents the four bytes 0x62 0x62 0x62 0xdc.  This is not
valid UTF-8.  So, you get an assertion error because you must pass valid
UTF-8 to essentially all Gtk+ function.  If you take untrusted strings
use g_utf8_validate() to validate them and reject those that do not
pass.

> So
> my question is how can I get Gtk::TextView to display the decoded base64?

This is nonsensical question.  Base64 does not have anything to do with
it.  Your text is the sequence of four bytes above and it is invalid.
Why it is invalid?  Hard to tell.  Base64 is just a change of
representation of the same invalid sequence of bytes.

Yeti

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux