I have build a web application with ruby on rails. With:
Ruby: ruby 1.9.2p290
Rails: rails (3.0.7)
Database: SQL Server 2008 R2
I've tested it in my local with input Chinese Traditional character into the input/textbox and create the data. it's working fine.
The data: 長壽
Result in Table SQL Server that using varchar(255) SQL_Latin1_General_CP1_CI_AS
is: 長壽
With this, I also can view the text in UI.
But when I gave the application, ruby gem, and the preferences to my friends, they cannot input the Chinese Traditional character. it said, "incompatible character encodings: ASCII-8BIT and UTF-8
" when click save button.
Even I restore my database into them, the web application cannot show the value properly it said "invalid byte sequence in UTF-8
". Although, They also using the same settings as mine, like SQL Server, version of ruby, and path.
The difference is only I'm using English version of Windows 10 and my friends using Chinese Language of Windows 10.
I have try:
1. config.encoding = "utf-8"
is already in application.rb file.
2. put # encoding: utf-8
on top of model and controller
3. Above Rails.application.initialize!
line in environment.rb
file, add following two lines:
--Encoding.default_external = Encoding::UTF_8
--Encoding.default_internal = Encoding::UTF_8
4. I also tried input encoding: utf8
in database.yml
, the data can be saved, but it become question mark ?? in table database and when I want to view it, it also said "invalid byte sequence in UTF-8".
Any more information, i can give it to you if needed. :)