Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
Rails Chinese question 1. Set UTF-8 to encoded format when MySQL is installed. It is said that modifying the configuration file does not work, it is only useful if you set up the encoding format when you install the database. 2. Set the encoding format in the database.yml of your rails project Development:adapter:mysql database:cn_development
Encoding:utf8Username:root Password:eman host:localhost 3. Set all rhtml file encoding formats for UTF-8 < head >
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8"/>< title > Book: <%= controller.action_name%> </title > <%= stylesheet_link_tag ' scaffold '%> /head > At this point, the Rails program's interface should be able to display Chinese correctly, whether it is the text on the page, or the Chinese reading and writing from the database, can be displayed correctly. 4. But there are some small problems, through the rails program on the database read and write when the console on the display of garbled, while using CMD access to the database, also show a tangle. This is mainly because Windows Cmd/console only supports GBK, and the data is stored in UTF8 in the database, so it's a mess to read out and display with GBK. To resolve database cmd access you can set the encoding when connecting to the database to notify MySQL that it requires the data to be accepted with GBK encoding: Mysql-uroot-peman
--DEFAULT-CHARACTER-SET=GBK5.How to troubleshoot consoleshows the problem that needs further study.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.