Convert C++ std::string to and from ruby such that strings containing

zero bytes are handled correctly, as they are elsewhere.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9118 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-05-15 02:01:05 +00:00
commit b9dfced8ca

View file

@ -33,9 +33,9 @@ bool SWIG_STRING_P(VALUE x) {
return TYPE(x) == T_STRING;
}
std::string SWIG_RB2STR(VALUE x) {
return std::string(StringValuePtr(x));
return std::string(RSTRING(x)->ptr, RSTRING(x)->len);
}
VALUE SWIG_STR2RB(const std::string& s) {
return rb_str_new2(s.c_str());
return rb_str_new(s.data(), s.size());
}
%}