I'm trying to make a C extension for Ruby that includes a method that returns a string that will sometimes have character values that should be in an unsigned char . At http://github.com/shyouhei/ruby/blob/trunk/README.EXT, all functions listed to include C strings in Ruby strings accept signed characters. Therefore, I could not do this:
unsigned char bytes[] = {0xf0, 0xf1, 0xf2}; return rb_str_new(bytes, 3);
How can I create a method that returns these types of strings? In other words, how do I make a C extension using a method that returns "\xff" ?
source share