Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I encode files to UTF-8 for Rails 3?
    primarykey
    data
    text
    <p>I've been working on outlook imports (linked in exports to outlook format) but I'm having troubles with encoding. The outlook format CSV I get from exporting my LinkedIn contacts are not in UTF-8. Letters like <code>ñ</code> cause an exception in the <code>mongoid_search</code> gem when calling <code>str.to_s.mb_chars.normalize</code>. I think encoding is the issue, because when I call <code>mb_chars</code> (<a href="http://apidock.com/rails/String/mb_chars" rel="nofollow">see first code example</a>). I am not sure if this is a bug in the gem, but I was advised to sanitize the data nonetheless.</p> <p>From File Picker, I tried using their new, community-supported gem to upload CSV data. I tried three encoding detectors and transcoders:</p> <ol> <li>Ruby port of a Python lib <code>chardet</code> <ul> <li>Didn't work as expected</li> <li>The port still contained Python code, preventing it from running in my app</li> </ul></li> <li><code>rchardet19</code> gem <ul> <li>Detected <code>iso-8859</code> with <code>.8/1</code> confidence. </li> <li>Tried to transcode with Iconv, but crashed on "illegal characters" at <code>ñ</code></li> </ul></li> <li><a href="https://github.com/brianmario/charlock_holmes" rel="nofollow"><code>Charlock_Holmes</code></a> gem <ul> <li>Detected <code>windows-1252</code> with <code>33/100</code> confidence</li> <li>I assume that's the actual encoding, and <code>rchardet</code> got <code>iso-8859</code> because this ones based of that. </li> <li>This gem uses ICU and has a maintained branch "bundle-icu" which supports Heroku. When I try to transcode using <code>charlock</code>, I get the error <code>U_FILE_ACCESS_ERROR</code>, an ICU error code meaning "could not open file"</li> </ul></li> </ol> <p>Anybody know what to do here?</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.
    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