FFI wide-character type?

John M McIntosh johnmci at smalltalkconsulting.com
Thu Aug 3 04:13:55 UTC 2006


Likely many ways.

However the trick is converting from a WideString to or from another  
format.
So for example if I have a UTF16 string I can make a WideString via

aWideString := utf16String convertFromWithConverter:  
(UTF16TextConverter new).

or convert back with

utf16String := aWideString convertToWithConverter:  
(UTF16TextConverter new useByteOrderMark: true).

I'll note that if you have a string (8 bits) in Squeak you must  
decide what the bits mean, is that a
latin 1 string, a mac roman, or something else.


	converter := Smalltalk platformName = 'Mac OS'
		ifTrue:  [MacRomanUnicodeTextConverter new]
		ifFalse: [Latin1TextConverter new].
	wideStringMangled := string convertFromWithConverter: converter.



On 2-Aug-06, at 8:57 PM, Ron Teitelbaum wrote:

> All,
>
> The code I was writing worked in C++ but didn't in FFI, it turns  
> out that I
> didn't quite understand the string L"MY".
>
> It turns out that this is a wide-character string.
>
> To specify a string of type wide-character (wchar_t[]), precede the  
> opening
> double quotation mark with the character L. For example:
> wchar_t wszStr[] = L"1a1g";
>
> Is it possible to send a wide-character, or to change the string so  
> that it
> looks like a wide character to FFI?
>
> I've tried sending in WideString fromString: 'MY' but I get "can't  
> coerce
> arguments".  I've tried changing the arguments to accept the wide  
> string but
> that didn't work either.
>
> Thanks for your help!
>
> Ron Teitelbaum
>
>
>

--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===





More information about the Squeak-dev mailing list