On Wed, 2015-03-11 at 18:09 -0600, Daniel Espinosa wrote: > I've used this for encode/decode strings in a GTK app, is it necessary to > call GLib.Intl.setlocale at app start?
It depends on what you want to do. It doesn't alter the encoding/decoding, it alters how printf (and other functions behave). > And if it is a GLIB library, should I call setlocale to initialize it? Not completely sure what you're asking, so a few points: * The application should be calling setlocale, not a library. * Using glib does not preclude you from having to call setlocale. * You should call setlocale if the C locale isn't appropriate for you. It's 7 bit ASCII, so if you have an "á" somewhere then yes, you probably need to call it. You might want to consider reading the setlocale(3) man page and/or section 7.11.1 of the C11 standard (or the corresponding part of C89 or C99—I don't have those handy, though, so I can't give you the section number). > > El mar 10, 2015 8:14 PM, "Evan Nemerson" <e...@coeus-group.com> escribió: > > > > It decodes fine. The same thing happens when you try to print t instead > > of s2. You forgot to call setlocale: > > > > GLib.Intl.setlocale (GLib.LocaleCategory.ALL, ""); > > > > Or, if you're using 0.28, just GLib.Intl.setlocale(); will work. > > > > > > On Tue, 2015-03-10 at 16:43 -0600, Daniel Espinosa wrote: > > > I would like to know how Vala Base64 encode/decode UTF-8 strings. > > > > > > If my string have no special characters, Base64 encode/decode works > > > flawlessly. > > > > > > But if it has a character like "á" it fails to decode, well when try to > > > cast to string fails. > > > > > > Code: > > > > > > public class App : Object > > > { > > > public static void main () > > > { > > > var app = new App (); > > > var t = "á"; > > > var s = GLib.Base64.encode (t.data); > > > var s2 = GLib.Base64.decode (s); > > > GLib.message ("TEXT: "+(string)s2); > > > } > > > } > > > > > > Text printed is: > > > > > > ** Message: string.vala:10: TEXT: ? > > > > > > Expected message should be: > > > > > > ** Message: string.vala:10: TEXT: á > > > > > > Please help me. > > > > > > >
signature.asc
Description: This is a digitally signed message part
_______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list