Created
September 11, 2014 17:35
-
-
Save wyattisimo/534f5138c084f11bbc30 to your computer and use it in GitHub Desktop.
unicode patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveSupport::JSON::Encoding | |
def self.escape(string) | |
if string.respond_to?(:force_encoding) | |
string = string.encode(::Encoding::UTF_8, :undef => :replace).force_encoding(::Encoding::BINARY) | |
end | |
json = string.gsub(escape_regex) { |s| ESCAPED_CHARS[s] } | |
json = %("#{json}") | |
json.force_encoding(::Encoding::UTF_8) if json.respond_to?(:force_encoding) | |
json | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment