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.
> 


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

Reply via email to