From b9dfced8ca48c4c15c1641f66e2be6504fe66aee Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 15 May 2006 02:01:05 +0000 Subject: [PATCH] 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 --- SWIG/Lib/ruby/std_common.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SWIG/Lib/ruby/std_common.i b/SWIG/Lib/ruby/std_common.i index af5edd0e1..49a8a297b 100644 --- a/SWIG/Lib/ruby/std_common.i +++ b/SWIG/Lib/ruby/std_common.i @@ -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()); } %}