This is probably one of the weirdest questions that i had to ask in Stackoverflow :)
I have a legacy, non-tested PHP application which i can't touch at all. This application uses Mysql and one database per account. So we have thousands of databases.
Due to an error that was there way before i started working on it, this app connects with the wrong encoding in Mysql. So in database, where we were supposed to have "é" we actually get "é". Although in application ( due to the wrong connection encoding ), we get é.
I have a Rails application that manage the creation of accounts/databases. The problem is that the Rails application is using the correct encoding and when it creates the database, it will insert some data which the PHP application can't read properly.
My question: considering that i have a string "é" in Ruby, how to i intentionally change it to "é"? Any string.encode that i can use?
Note 1: I can't dump all databases and fix this ( which would be the ideal solution )
Note 2: I can't switch Rails connection encoding as it uses another database which has the correct encoding
You can try to have the default charset as
in config/application.rb
The original PHP encoding looks like to be ISO 8859-1 or Windows-1252
I tried this on a irb and found that this is working