Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In Ruby 1.9, encoding is explicit now. However, Rails may or may not be configured to send the responses in the encoding you expect. You'll have to set the global configuration setting:</p> <pre><code>Encoding.default_external = "utf-8". </code></pre> <p>I believe the encoding that Ruby specifies by default for serialization is the platform default. In America on Windows that would be CodePage-1251. Other countries would have an alternate encoding.</p> <p><strong>Edit</strong>: Also see this url if the json is executed against MySQL: <a href="https://rails.lighthouseapp.com/projects/8994/tickets/5210-encoding-problem-in-json-format-response" rel="nofollow">https://rails.lighthouseapp.com/projects/8994/tickets/5210-encoding-problem-in-json-format-response</a> </p> <p><strong>Edit 2</strong>: Rails core and its suite of libraries (ActiveRecord, et. al.) will respect the Encoding.default_external configuration setting which encodes all the values it sends. Unfortunately, because encoding is a relatively new concept to Ruby not every 3rd party library has been adjusted for proper encoding. The ones that have may require additional configuration settings for those libraries. This includes MySQL, and the RSolr library you were using.</p> <p>In all versions of Ruby before the 1.9 series, a string was just an array of bytes. When you've been thinking like that for so long, it's hard to wrap your head around the concept of multiple string encodings. The thing that is even more confusing now is that unlike Java, C#, and other languages that use some form of UTF as the native string format, Ruby allows each string to be encoded differently. In retrospect, that might be a mistake, but at least now they are respecting encoding.</p> <p>The <code>Encoding.force_encoding</code> method is designed to treat the byte sequence with that new encoding, but does not change any of the underlying data. So it is possible to have invalid byte sequences. There is another method called <code>.encode()</code> that will transform the bytes from one encoding to another and guarantees valid byte sequences. For more information read this:</p> <p><a href="http://blog.grayproductions.net/articles/ruby_19s_string" rel="nofollow">http://blog.grayproductions.net/articles/ruby_19s_string</a></p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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