Subject:
[ruby-ffi] 'encoding' type?
From:
dubl
Date:
1/7/11 1:18 AM
To:
ruby-ffi

hello,
i'm trying to attach CFStringCreateWithCString..

below is the reference documentation, which allows you to pass null as
the first argument, a cstring as the second, and an 'encoding' as the
third..

my question is, how do i attach this?  i'm trying
  attach_function :CFStringCreateWithCString,
[:void,:char,:int], :void
..using ':int', its erroring out saying 'invalid parameter type' for
the 0 I pass it...

question is: what symbol do i give it as the third argument, and then
what do i pass it?

I admit I'm new to the concept. this is my first attempt at FFI... i'm
trying to rewrite an old dl/importable version which used the int,
passing it a 0, and it worked fine.

thanks for the opportunity to ask the question.

Jon

----------------
CFStringRef CFStringCreateWithCString (
   CFAllocatorRef alloc,
   const char *cStr,
   CFStringEncoding encoding
);
Parameters
alloc
The allocator to use to allocate memory for the new string. Pass NULL
or kCFAllocatorDefault to use the current default allocator.
cStr
The NULL-terminated C string to be used to create the CFString object.
The string must use an 8-bit encoding.
encoding
The encoding of the characters in the C string. The encoding must
specify an 8-bit encoding.
---------------------