I am using js-ctypes to work with a shared library from Firefox under Linux.

Under certain circumstances when I am using the readString() method to convert an array of char in c to a string in javascript, I am getting the following error:

TypeError: malformed UTF-8 character sequence at offset 502

This happens when I have some special characters in the string, and as understand it is due to conversion problems. How can I bypass this? Has anybody met this problem and somehow resolved it?