File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ static VALUE make_ruby_object(dom::element element)
27
27
for (dom::key_value_pair field : dom::object (element))
28
28
{
29
29
std::string_view view (field.key );
30
- VALUE k = rb_intern ( view.data ());
30
+ VALUE k = rb_intern_str ( rb_utf8_str_new ( view.data (), view. size () ));
31
31
VALUE v = make_ruby_object (field.value );
32
32
rb_hash_aset (hash, ID2SYM (k), v);
33
33
}
@@ -48,7 +48,7 @@ static VALUE make_ruby_object(dom::element element)
48
48
case dom::element_type::STRING:
49
49
{
50
50
std::string_view view (element);
51
- return rb_str_new (view.data (), view.size ());
51
+ return rb_utf8_str_new (view.data (), view.size ());
52
52
}
53
53
case dom::element_type::BOOL:
54
54
{
Original file line number Diff line number Diff line change @@ -7,6 +7,17 @@ def test_that_it_has_a_version_number
7
7
refute_nil ::FastJsonparser ::VERSION
8
8
end
9
9
10
+ def test_string_encoding
11
+ result = FastJsonparser . parse ( '"École"' )
12
+ assert_equal Encoding ::UTF_8 , result . encoding
13
+ end
14
+
15
+ def test_symbols_encoding
16
+ hash = FastJsonparser . parse ( '{"École": 1}' )
17
+ assert_includes hash , :"École"
18
+ assert_equal Encoding ::UTF_8 , hash . keys . first . encoding
19
+ end
20
+
10
21
def test_json_load_from_file_is_working
11
22
result = FastJsonparser . load ( "./benchmark/graduation.json" )
12
23
assert_equal result [ :meta ] . length , 1
You can’t perform that action at this time.
0 commit comments