From: Iñaki Baz Castillo on
Hi, when I create a Ruby String from a C extension by using "rb_str_new(s,
len)" I get a String with US-ASCII encoding.

I don't want to call later String#force_encoding(:"UTF-8") but instead use the
rb_enc_str_new() function in string.c:


VALUE
rb_enc_str_new(const char *ptr, long len, rb_encoding *enc)
{
VALUE str = rb_str_new(ptr, len);
rb_enc_associate(str, enc);
return str;
}

But I have no idea on how to set 'enc' parameter to be "UTF-8".
How should I fill the third 'enc' argument?

Thanks a lot.

--
Iñaki Baz Castillo <ibc(a)aliax.net>

 | 
Pages: 1
Prev: Graphics mode
Next: duda sobre nuevo metodo