diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-25 03:40:59 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-25 03:40:59 -0800 |
commit | 97636d95227b73e3875732fa61fa1d44157d32f1 (patch) | |
tree | d4ccf417d4ed7c999b574ba941cf9ecb68f7882c /activesupport/lib/active_support/json/encoding.rb | |
parent | 4c1701c0ca6ae77a8274f59460751d1b1d83ce1b (diff) | |
parent | 1e9e88fcd335c7d5a99159d592c3e1b605510a16 (diff) | |
download | rails-97636d95227b73e3875732fa61fa1d44157d32f1.tar.gz rails-97636d95227b73e3875732fa61fa1d44157d32f1.tar.bz2 rails-97636d95227b73e3875732fa61fa1d44157d32f1.zip |
Merge pull request #4180 from lest/remove-encoding-related
remove checks for encodings availability
Diffstat (limited to 'activesupport/lib/active_support/json/encoding.rb')
-rw-r--r-- | activesupport/lib/active_support/json/encoding.rb | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb index 925fa2a2c7..d7181035d3 100644 --- a/activesupport/lib/active_support/json/encoding.rb +++ b/activesupport/lib/active_support/json/encoding.rb @@ -119,9 +119,7 @@ module ActiveSupport end def escape(string) - if string.respond_to?(:force_encoding) - string = string.encode(::Encoding::UTF_8, :undef => :replace).force_encoding(::Encoding::BINARY) - end + string = string.encode(::Encoding::UTF_8, :undef => :replace).force_encoding(::Encoding::BINARY) json = string. gsub(escape_regex) { |s| ESCAPED_CHARS[s] }. gsub(/([\xC0-\xDF][\x80-\xBF]| @@ -130,7 +128,7 @@ module ActiveSupport s.unpack("U*").pack("n*").unpack("H*")[0].gsub(/.{4}/n, '\\\\u\&') } json = %("#{json}") - json.force_encoding(::Encoding::UTF_8) if json.respond_to?(:force_encoding) + json.force_encoding(::Encoding::UTF_8) json end end @@ -281,4 +279,4 @@ class DateTime strftime('%Y/%m/%d %H:%M:%S %z') end end -end
\ No newline at end of file +end |