[Vala] Base64 encode/decode



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.

-- 
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los
cuates: LIBRE)


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