On Thu, Apr 20, 2017 at 5:10 AM Sven Wick <sven.w...@gmx.de> wrote:

> Hi Philip,
>
> thanks for the hint with the ByteArray.
>
>     const ByteArray = imports.byteArray;
>
>     let a = new ByteArray.ByteArray();
>     let b = new ByteArray.ByteArray();
>
>     a[0] = 97;
>     a[1] = 98;
>
>     b[0] = 'a' ;
>     b[1] = 'b' ;
>
>     print(a);
>     print(b);
>
> prints
>
>   ab
>   <blank>
>
> Haven't figured out how to solve it yet...
>

Hi Sven,

ByteArray deals with byte values, not strings. So you have to either do
this:

b[0] = 'a'.charCodeAt(0);
b[1] = 'b'.charCodeAt(0);

or create it explicitly from a string like this:

b = ByteArray.fromString('ab');

Best,
Philip C
_______________________________________________
javascript-list mailing list
javascript-list@gnome.org
https://mail.gnome.org/mailman/listinfo/javascript-list

Reply via email to