aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json
diff options
context:
space:
mode:
authorSergey Nartimov <just.lest@gmail.com>2011-12-25 14:34:58 +0300
committerSergey Nartimov <just.lest@gmail.com>2011-12-25 14:34:58 +0300
commit1e9e88fcd335c7d5a99159d592c3e1b605510a16 (patch)
treed4ccf417d4ed7c999b574ba941cf9ecb68f7882c /activesupport/lib/active_support/json
parent4c1701c0ca6ae77a8274f59460751d1b1d83ce1b (diff)
downloadrails-1e9e88fcd335c7d5a99159d592c3e1b605510a16.tar.gz
rails-1e9e88fcd335c7d5a99159d592c3e1b605510a16.tar.bz2
rails-1e9e88fcd335c7d5a99159d592c3e1b605510a16.zip
remove checks for encodings availability
Diffstat (limited to 'activesupport/lib/active_support/json')
-rw-r--r--activesupport/lib/active_support/json/encoding.rb8
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