From 6c4a6644e687d9f801de6117e3e5caa33ad7f7d4 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Tue, 23 Jun 2009 20:17:59 +0900 Subject: [PATCH] use UTF-8 instead of BINARY --- activesupport/lib/active_support/json/encoding.rb | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb index 068b58b..120c427 100644 --- a/activesupport/lib/active_support/json/encoding.rb +++ b/activesupport/lib/active_support/json/encoding.rb @@ -1,4 +1,4 @@ -# encoding: binary +# encoding: utf-8 require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/object/instance_variables' @@ -94,7 +94,7 @@ module ActiveSupport end def escape(string) - string = string.dup.force_encoding(::Encoding::BINARY) if string.respond_to?(:force_encoding) + string.encode! if string.respond_to?(:encode!) json = '"' + string.gsub(escape_regex) { |s| ESCAPED_CHARS[s] } json.gsub(/([\xC0-\xDF][\x80-\xBF]| [\xE0-\xEF][\x80-\xBF]{2}| -- 1.6.3.3