We have a project which needs to show foreign language, like Chinese, on a web page. And we are using RICO 2.0, PHP, MySQL & ASP.NET in the project. To achieve this, we decide to use UTF-8 character set and the following changes need to be done:
To store UTF-8 in a table field, you need to set column’s charset => utf8 and collate => utf8_unicode_ci
- Web Page:
To show foreign language in a web page, the page file has to be saved as encoding UTF-8
The default encoding for PHP 5 is UTF-8, so it supports foreign language. But if you use PHP to retrieve UTF-8 characters from MySQL, you must add mysql_query(‘SET NAMES utf8’); after connecting to MySQL database for setting up the connection encoding.
As for RICO Live gird, Ajax response must start with <?xml version=”1.0″ encoding=”utf-8″?>
First make sure you have following line in you web.config
<globalization requestEncoding=”utf-8″ responseEncoding=”utf-8″ fileEncoding=”utf-8″/>
Second, keep both .aspx and code behind file save as the same encoding UTF-8
If you need to access the UTF-8 characters in MySQL database, be sure to use MySQL Connector/Net 5.0 or up with undocumented setting: charset=utf8 in connection string. We tried ODBC driver for MySQL, it doesn’t work properly with UTF-8.