by rubyrescue · 16y ago · 0 comments
i totally respect the need in the ruby community to support different charsets, but i wish ruby 1.9.1 had a mode where we could say DEFAULT_CHARSET_IN_CASE_OF_INCOMPATIBLE_ENCODING= "utf-8" and then it would convert to that encoding when in doubt. Would totally solve our issues.
details:
We just moved a fairly large Rails 2.3.4 app to 1.9.1 this week and have run into a number of 'incompatible charset encoding' issues.
My client is running a site that sends middle american students to middle american colleges. There's not a foreign character or thought in sight (which is a separate issue). However, our content writers occasionally use MS Word and a "smart quote" slips into the uploaded content.
When that happens, our rails HAML layout is in one encoding, and the partial that renders the smart-quote-bomb text from the database are now in different encodings, and the page errors.
The solution is to write a custom sanitize() method on string that forces encodings and gsubs away smart quotes. The consequences of missing one in 1.9.1 are just higher than in 1.8.7.
No comments yet.