jameskilton/rice — Issue #35: String encoding specification
Author: stevenbedrick
Created: 2012-01-04 17:22:59+00:00
State: open

Not sure if this is an issue or just something missing in the docs, but I can't seem to find a way to tell the Rice `std::string` `to_ruby()` method what encoding to use; everything's coming out as 8-bit ASCII. I know my `std::string`'s encoding a priori in this particular case.

Using Ruby's `String#force_encoding` on the results of `to_ruby()` solves the problem, so the right bytes are coming through, but it seems like there ought to be a way to do it from the get-go in Rice. I know that the 1.9 C API has some methods to do this (`rb_str_export_to_enc`, etc.), and it looks like it should also be possible to do using `rb_funcall` as well (see http://www.ruby-forum.com/topic/203865 ). Any ideas?