diff --git a/src/utilities/core/CommonImport.i b/src/utilities/core/CommonImport.i index 2004bde55b5..b35dae77900 100644 --- a/src/utilities/core/CommonImport.i +++ b/src/utilities/core/CommonImport.i @@ -11,6 +11,17 @@ #include #include #include + +#if defined SWIGRUBY + extern "C" { + #ifdef HAVE_RUBY_ENCODING_H + #include "ruby/encoding.h" + #endif + + rb_encoding *rb_utf8_encoding(void); + ID rb_intern3(const char *name, long len, rb_encoding *enc); + } +#endif %} %include diff --git a/src/utilities/core/jsoncpp.i b/src/utilities/core/jsoncpp.i index 4ebf7aa1c51..affa3d50030 100644 --- a/src/utilities/core/jsoncpp.i +++ b/src/utilities/core/jsoncpp.i @@ -73,7 +73,9 @@ #endif #if defined SWIGRUBY + %fragment("JsonToDict","header", fragment="SWIG_FromCharPtrAndSize") { + SWIGINTERN VALUE SWIG_From_JsonValue(const Json::Value& value) { if (value.isNull()) { @@ -108,7 +110,10 @@ if (value.isObject()) { VALUE result = rb_hash_new(); for( const auto& id : value.getMemberNames()) { - rb_hash_aset(result, ID2SYM(rb_intern(id.data())), SWIG_From_JsonValue(value[id])); + rb_hash_aset(result, + ID2SYM(rb_intern3(id.data(), id.size(), rb_utf8_encoding())), + SWIG_From_JsonValue(value[id]) + ); } return result; }