title: can server locale settings affect JSON parsing (Ruby)
body: <p>I have an issue with a script that is parsing some data which is stored in Redis, the particular hash of data has this in a string:</p>
  
  <pre><code>\u00a3575,000. which is £575,000
  </code></pre>
  
  <p>Redis is storing it as a £ when i pull it out. But when I pass the string to JSON.parse it returns an error saying:</p>
  
  <pre><code>Unexpected error while processing request: "\xC2" on US-ASCII
  </code></pre>
  
  <p>I have been through the server and tested it on our UAT platform and it is fine, it parses fine and returns exactly what I expect, however on the live server which is the same as the UAT server (Ruby version, RVM version, Redis version) it gives the above error.</p>
  
  <p>I have been through the server settings and the only thing I can see different is the locale settings (Ubuntu 12.04)</p>
  
  <pre><code>on UAT its set to en_GB.UTF-8 
  on live its set to en_US.UTF-8
  </code></pre>
  
  <p>Before I left the office I changed the locale settings, but ran out of time to reboot the server and can't now until tomorrow morning (its IP locked for ssh to the office). However like most coders I know, I can't stop thinking about the problem, hence coming to ask here if it can make a difference. If it can't can anyone point me in the right direction to come up with a solution?</p>
  
  <p>ps. I did add this line:</p>
  
  <pre><code>result = result.force_encoding(Encoding::UTF_8)
  </code></pre>
  
  <p>which worked but feel that, as I didn't need to do this on UAT, it feels wrong to make a code change like that to bend to a problem with the environment.</p>
  
  <p>many thanks</p>
  
  <p>ops: if this helps answer why i am getting the error, then: my output from rvm info
  ruby-2.1.1:</p>
  
  <pre><code>  system:
      uname:       "Linux ip-10-82-168-126 3.2.0-54-virtual #82-Ubuntu SMP Tue Sep 10 20:31:18 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux"
      system:      "ubuntu/12.04/x86_64"
      bash:        "/bin/bash =&gt; GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)"
      zsh:         " =&gt; not installed"
  
    rvm:
      version:      "rvm 1.25.27 (stable) by Wayne E. Seguin &lt;wayneeseguin@gmail.com&gt;, Michal Papis &lt;mpapis@gmail.com&gt; [https://rvm.io/]"
      updated:      "3 hours 15 minutes 33 seconds ago"
      path:         "/usr/local/rvm"
  
    ruby:
      interpreter:  "ruby"
      version:      "2.1.1p76"
      date:         "2014-02-24"
      platform:     "x86_64-linux"
      patchlevel:   "2014-02-24 revision 45161"
      full_version: "ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]"
  
    homes:
      gem:          "/usr/local/rvm/gems/ruby-2.1.1"
      ruby:         "/usr/local/rvm/rubies/ruby-2.1.1"
  
    binaries:
      ruby:         "/usr/local/rvm/rubies/ruby-2.1.1/bin/ruby"
      irb:          "/usr/local/rvm/rubies/ruby-2.1.1/bin/irb"
      gem:          "/usr/local/rvm/rubies/ruby-2.1.1/bin/gem"
      rake:         "/usr/local/rvm/rubies/ruby-2.1.1/bin/rake"
  
    environment:
      PATH:         "/usr/local/rvm/gems/ruby-2.1.1/bin:/usr/local/rvm/gems/ruby-2.1.1@global/bin:/usr/local/rvm/rubies/ruby-2.1.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local.rvm/bin:/usr/local/rvm/bin"
      GEM_HOME:     "/usr/local/rvm/gems/ruby-2.1.1"
      GEM_PATH:     "/usr/local/rvm/gems/ruby-2.1.1:/usr/local/rvm/gems/ruby-2.1.1@global"
      MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-2.1.1"
      IRBRC:        "/usr/local/rvm/rubies/ruby-2.1.1/.irbrc"
      RUBYOPT:      ""
      gemset:       ""
  </code></pre>