[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to export binary string from C to ruby?

Hadmut Danisch

10/20/2004 11:49:00 AM

Hi,

I'd like to write a ruby method in C, which passes an
arbitrary byte string as a result back to ruby.

All functions I found (like rb_str_new2 ) use
just a pointer and assume the string to be 0-terminated.

Any way to convert a buffer into a ruby string based
on pointer and length?

regards
Hadmut


1 Answer

Richard Dale

10/20/2004 12:25:00 PM

0

spamblock@danisch.de wrote:

> Hi,
>
> I'd like to write a ruby method in C, which passes an
> arbitrary byte string as a result back to ruby.
>
> All functions I found (like rb_str_new2 ) use
> just a pointer and assume the string to be 0-terminated.
>
> Any way to convert a buffer into a ruby string based
> on pointer and length?
I don't think rb_str_new() expects a null terminator:

VALUE rb_str_new _((const char*, long));

-- Richard