Difference "Encoding and UTF-8" ver. 5 versus ver. 6
Content:
<!--toc--> |
|
Today, UTF-8 is widely considered the standard encoding for the web. Thus, it is important that your application handles encoding problems properly. |
|
## HTTP |
|
It is not enough that the template of your HTML page contains the following declaration: |
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|
|
The page must be sent over HTTP over a UTF-8 connection, as declared in the HTTP headers. To achieve this, you must add a UTF-8 locale in the configuration file of your cppcms application, e.g.: |
|
"localization" { |
"locales" : [ "en_US.UTF-8" ] |
} |
|
## SQL |
|
The default encoding of the connection to your SQL server may not be UTF-8. To ensure that the data which is stored as UTF-8 in your database is retrieved appropriately, make sure to configure the connection to use UTF-8: |
|
|
cppdb::session sql(database_connection_string); |
sql << "SET NAMES \"utf8\"" << cppdb::exec; |
|
|
|
<!--toc-->
|
|
Today, UTF-8 is widely considered the standard encoding for the web. Thus, it is important that your application handles encoding problems properly.
|
|
## HTTP
|
|
It is not enough that the template of your HTML page contains the following declaration:
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
The page must be sent over HTTP over a UTF-8 connection, as declared in the HTTP headers. To achieve this, you must add a UTF-8 locale in the configuration file of your cppcms application, e.g.:
|
|
"localization" {
|
"locales" : [ "en_US.UTF-8" ]
|
}
|
|
## SQL
|
|
The default encoding of the connection to your SQL server may not be UTF-8. To ensure that the data which is stored as UTF-8 in your database is retrieved appropriately, make sure to configure the connection to use UTF-8:
|
|
|
cppdb::session sql(database_connection_string);
|
sql << "SET NAMES \"utf8\"" << cppdb::exec;
|
|
|
|
|
Sidebar:
|
← [Customize your "Page not found | 404" page](http://cppcms.com/wikipp/en/page/cppcms_1x_tut_404)
|
[Reload the application](http://cppcms.com/wikipp/en/page/cppcms_1x_reload_application)→ |
About
CppCMS is a web development framework for performance demanding applications.
Support This Project
Navigation
Main Page
Valid CSS
| Valid XHTML 1.0