Re: [Vala] Base64 encode/decode



I've used this for encode/decode strings in a GTK app, is it necessary to
call GLib.Intl.setlocale at app start?

And if it is a GLIB library,  should I call setlocale to initialize it?

El mar 10, 2015 8:14 PM, "Evan Nemerson" <evan 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.





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