before cramming utf8 data into us-ascii, replace "smart" quotes and things

This commit is contained in:
joshua stein 2013-07-01 14:28:39 -05:00
parent a471eb180a
commit 1ae4c141a3

View file

@ -9,6 +9,14 @@ Rails.application.require_environment!
class String
def force_to_ascii
# fixup some "smart" quotes and things instead of forcing them to "?" chars
gsub("\u201C", '"').
gsub("\u201D", '"').
gsub("\u2018", "'").
gsub("\u2019", "'").
gsub("\u2013", "-").
gsub("\u2014", "--").
gsub("\u2026", "...").
encode("us-ascii", :invalid => :replace, :undef => :replace,
:replace => "?")
end