Put this in application_helper.rb: def u(html) h(html).gsub(/([^x00-x9f])/u) { |s| “&#x%x;” % $1.unpack(‘U’)[0] } end This will automatically output 香-style HTML entities where needed. I’m using it for escaping HTML inside of Edge Rails .rjs templates, to ensure compatibility across browsers (especially Safari seems to be a bit buggy here with support for UTF-8 in Ajax … Continue reading Unicode-escaping h() variant
Copy and paste this URL into your WordPress site to embed
Copy and paste this code into your site to embed