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:
parent
1042bce00c
commit
b9dfced8ca
1 changed files with 2 additions and 2 deletions
|
|
@ -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());
|
||||
}
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue