How to export binary string from C to ruby?

G

Guest

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
 
R

Richard Dale

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,068
Latest member
MakersCBDIngredients

Latest Threads

Top