From b823c351c1def9e9f3683069f4f682dffae3a660 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 7 Aug 2011 21:07:44 +0200 Subject: [PATCH] make symbolizing and the spec work again on 1.8 --- ext/yajl/yajl_ext.c | 5 +++-- spec/parsing/one_off_spec.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ext/yajl/yajl_ext.c b/ext/yajl/yajl_ext.c index 8d6ee939..264cefa1 100644 --- a/ext/yajl/yajl_ext.c +++ b/ext/yajl/yajl_ext.c @@ -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 { diff --git a/spec/parsing/one_off_spec.rb b/spec/parsing/one_off_spec.rb index 5b3c39e5..39efe315 100644 --- a/spec/parsing/one_off_spec.rb +++ b/spec/parsing/one_off_spec.rb @@ -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