ruby c extensions: character values over 127
Posted
by Adrian
on Stack Overflow
See other posts from Stack Overflow
or by Adrian
Published on 2010-04-24T17:52:33Z
Indexed on
2010/04/24
23:53 UTC
Read the original article
Hit count: 312
I am trying to make a C extension for Ruby that includes a method returning a string, which will sometimes have character values that need to be in an unsigned char
. In http://github.com/shyouhei/ruby/blob/trunk/README.EXT, all of the functions listed for turning C strings into Ruby strings take signed chars. So I couldn't do this:
unsigned char bytes[] = {0xf0, 0xf1, 0xf2};
return rb_str_new(bytes, 3);
How could I make a method that returns these types of strings? In other words, how would I make a C extension with a method returning "\xff"
?
© Stack Overflow or respective owner