FFI wide-character type?
Ron Teitelbaum
Ron at USMedRec.com
Thu Aug 3 22:38:06 UTC 2006
John,
Thanks for the suggestion.
What I have is a smalltalk string. I need to send it to the external
function as a widestring. I tried to find a smalltalk string that I could
try sending as char* by trying this:
TextConverter allSubclasses collect: [:aConverter |
'MY' convertFromWithConverter: aConverter new
]
I don't get anything different then a regular smalltalk string.
So that didn't work.
Do you have any other suggestions?
> From: John M McIntosh
> Sent: Thursday, August 03, 2006 12:14 AM
>
> 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
> >
> >
More information about the Squeak-dev
mailing list
|