Skip to content

Commit

Permalink
make symbolizing and the spec work again on 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger Braun committed Aug 7, 2011
1 parent eb6877d commit b823c35
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ext/yajl/yajl_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ static int yajl_found_hash_key(void * ctx, const unsigned char * stringVal, unsi
memcpy(buf, stringVal, stringLen);
buf[stringLen] = 0;
VALUE stringEncoded = rb_str_new2(buf);
int enc = rb_enc_find_index("UTF-8");
rb_enc_associate_index(stringEncoded, enc);
#ifdef HAVE_RUBY_ENCODING_H
rb_enc_associate(stringEncoded, rb_utf8_encoding());
#endif

yajl_set_static_value(ctx, ID2SYM(rb_to_id(stringEncoded)));
} else {
Expand Down
2 changes: 1 addition & 1 deletion spec/parsing/one_off_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
end

it "should parse using it's class method, from a utf-8 string with multibyte characters, with symbolized keys" do
Yajl::Parser.parse('{"日本語": 1234}', :symbolize_keys => true).should == {:日本語 => 1234}
Yajl::Parser.parse('{"日本語": 1234}', :symbolize_keys => true).should == {:"日本語" => 1234}
end

it "should parse using it's class method, from a string" do
Expand Down

0 comments on commit b823c35

Please sign in to comment.