summaryrefslogtreecommitdiff
path: root/ext/json/ext/parser/parser.rl
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-19 14:47:04 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-19 14:47:04 +0000
commitda3be0f3d323771b5dcfbc828375067ddc4ee611 (patch)
treeda44145a0bf440cefcf16703a9e751b74e95787e /ext/json/ext/parser/parser.rl
parent4b645dc8f3cb6c3a58ccd9b85962f743399dc797 (diff)
* ext/json/ext/parser/parser.rl, ext/json/ext/parser/parser.c: JSON
text SHALL be encoded in Unicode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json/ext/parser/parser.rl')
-rw-r--r--ext/json/ext/parser/parser.rl7
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl
index 840b8e0f10..c25b1278f7 100644
--- a/ext/json/ext/parser/parser.rl
+++ b/ext/json/ext/parser/parser.rl
@@ -3,6 +3,7 @@
#include "ruby.h"
#include "ruby/re.h"
#include "ruby/st.h"
+#include "ruby/encoding.h"
#include "unicode.h"
#define EVIL 0x666
@@ -332,7 +333,7 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
static VALUE json_string_unescape(char *p, char *pe)
{
- VALUE result = rb_str_buf_new(pe - p + 1);
+ VALUE result = rb_enc_str_new(0, pe - p + 1, rb_utf8_encoding());
while (p < pe) {
if (*p == '\\') {
@@ -406,7 +407,7 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
{
int cs = EVIL;
- *result = rb_str_new("", 0);
+ *result = rb_enc_str_new("", 0, rb_utf8_encoding());
%% write init;
json->memo = p;
%% write exec;
@@ -592,7 +593,7 @@ static void JSON_mark(JSON_Parser *json)
static void JSON_free(JSON_Parser *json)
{
- free(json);
+ ruby_xfree(json);
}
static VALUE cJSON_parser_s_allocate(VALUE klass)