0

My local (Mac) and remote (Ubuntu 14.04) MySQL database and table are in UTF-8. Local is using Ruby 2.2.0, remote is using Ruby 2.2.3.

On my local machine, I tested the script in IRB:

irb(main):004:0> item.at('title').text
=> "Öndör Gegeen Zanabazaryn Gudamj"

Then I ran the script ruby abc.rb and got it stored in the database exactly as

Öndör Gegeen Zanabazaryn Gudamj

On my remote machine, I tested the script on IRB:

irb(main):004:0> item.at('title').text
=> "\u00D6nd\u00F6r Gegeen Zanabazaryn Gudamj"

Then I ran the script ruby abc.rb but got it stored in the database as:

Öndör Gegeen Zanabazaryn Gudamj

What settings should I do on my remote in order to store the data correctly as my local?

Victor
  • 13,010
  • 18
  • 83
  • 146

1 Answers1

0

I switched to mysql2 gem from mysql gem, which automatically forces the use of UTF-8 [or binary] for the connection. So the problem lies on the database connection, not the database or the script.

Ref:

  1. Storing swedish characters in mysql database
  2. https://github.com/brianmario/mysql2
Community
  • 1
  • 1
Victor
  • 13,010
  • 18
  • 83
  • 146