FFI wide-character type?
yoshiki at squeakland.org
Tue Aug 15 03:26:04 UTC 2006
> aStream := MultiByteBinaryOrTextStream on: String new encoding: 'utf-16'.
> aStream converter useLittleEndian: true.
> aStream nextPutAll: 'abcde'.
> And it appears to work great except that the implementation of next throws
> it all away. I'm guessing it will work for ms wide strings -> squeak just
> fine, but doesn't support squeak -> ms wide strings very well. I figured
> I'd write an MSWideString class to support this properly. Do you have any
> suggestions and/or am I missing something?
If you have a ByteString that contains utf-16 encoded chars,
ret := aString convertFromWithConverter: (UTF16TextConverter new useLittleEndian: true).
should give you a correct ByteString or WideString.
For that matter, the conversion to an external format can be:
ret := 'abcde' convertToConverter: (UTF16TextConverter new useLittleEndian: true).
More information about the Squeak-dev