In my Gnome Extension I would like to call GLib.convert. Sadly it does not work with strings but wants a ByteArray. Now I wonder how to convert a Javascript String into a UTF-16 Byte Array.
Bonus points if this uses some part of the Gnome bindings instead of implementing in Javascript.
ByteArray.fromString(someString, 'UTF-16')will convert your JS string into a UTF-16-encodedUint8Array. This can be passed toGLib.convert(although, since fromString should understand all the encodings thatGLib.convertdoes, maybe you don't need to after that?)See also the ByteArray documentation.