Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I set the default string encoding on Ruby 1.9?
    primarykey
    data
    text
    <p>This might sound minor, but it's been driving me nuts. Since releasing an application to production last Friday on Ruby 1.9, I've been having lots of minor exceptions related to character encodings. Almost all of it is some variation on:</p> <pre><code>Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8 </code></pre> <p>We have an international user base so plenty of names contain umlauts, etc. If I fix the templates to use <strong>force_encoding</strong> in a bunch of places, it pops up in the flash message helper. Et cetera.</p> <p>At the moment it looks like I've nailed down all the ones I knew about, by patching ActiveSupport's string concatenation in one place and then by setting <code># encoding: utf-8</code> at the top of every one of my source files. But the feeling that I might have to remember to do that for every file of every Ruby project I ever do from now on, forever, just to avoid string assignment problems, does not sit well in my stomach. I read about the <strong>-Ku</strong> switch but everything seems to warn that it's for backwards compatibility and might go away at any time.</p> <p>So my question for 1.9-experienced folks: is setting <code>#encoding</code> in every one of my files <em>really</em> necessary? Is there a reasonable way to do this globally? Or, better, a way to set the default encoding on non-literal values of strings that bypass the internal/external defaults?</p> <p>Thanks in advance for any suggestions.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload