4 mattr_accessor
:escape_regex
22 ActiveSupport
.escape_html_entities_in_json
= true
25 def to_json(options
= nil) #:nodoc:
26 json
= '"' + gsub(ActiveSupport
::JSON::Encoding.escape_regex
) { |s
|
27 ActiveSupport
::JSON::Encoding::ESCAPED_CHARS[s
]
29 json
.force_encoding('ascii-8bit') if respond_to
?(:force_encoding)
30 json
.gsub(/([\xC0-\xDF][\x80-\xBF]|
31 [\xE0-\xEF][\x80-\xBF]{2}|
32 [\xF0-\xF7][\x80-\xBF]{3})+/nx
) { |s
|
33 s
.unpack("U*").pack("n*").unpack("H*")[0].gsub(/.{4}/, '\\\\u\&')