TooTallNate / ref

Turn Buffer instances into "pointers"
http://tootallnate.github.com/ref
453 stars 141 forks source link

ref.allocCString with encoding 'utf16le' #41

Closed zetsin closed 8 years ago

zetsin commented 8 years ago

Inside the function of ref.allocCString: var size = Buffer.byteLength(string, encoding) + 1

There is error while setting encoding 'utf16le', because utf16 string terminator is the two-byte sequence 0x00 0x00. Maybe you should do this: var size = Buffer.byteLength(string + '\0', encoding)

unbornchikken commented 8 years ago

That CString only supports characters of 1 bytes (see the implementation of write and read CString methods). That encoding is only for selecting ASCII or UTF8.

Maybe that would be a good idea to support wide strings, but I believe that gotta be a separate ref type, say, WString.

TooTallNate commented 8 years ago

Give https://github.com/TooTallNate/ref-wchar a shot!