When we connect MySQL database, we usually add useunicode=true&characterencoding=utf-8 after the URL, but ask what to add?
The purpose of the addition is to specify the encoding and decoding format of the characters.
For example: the MySQL database uses GBK encoding, and the project database uses UTF-8 encoding. If Useunicode=true&characterencoding=utf-8 is added at this time, then there are two aspects of the function:
1. When data is stored:
when storing the project data, the database decodes the data into bytecode using the UTF-8 format, and then the decoded bytecode is reused in the database using the GBK encoding.
2. When data is taken:
when fetching data from the database, the database will first decode the data in the database into bytecode in GBK format, then encode the decoded bytecode again in UTF-8 format, and then return the data to the client.
Note: When you configure Database utl in an XML configuration file, you use the & escape character, which is &
Example: <property name= "url" value= "jdbc:mysql://localhost:3306/email?useunicode=true&characterencoding= UTF-8 "/>
Special characters commonly used in HTML:
Most commonly used character entities (Character entities)
Show Results |
Description |
Entity Name |
Entity | Number
|
Show a space |
|
& #160; |
< |
Less than |
< |
& #60; |
> |
Greater than |
> |
& #62; |
& |
& Symbols |
& |
& #38; |
" |
Double quotes |
" |
& #34; |
Other commonly used character entities (Character entities)
Show Results |
Description |
Entity Name |
Entity | Number
© |
Copyright |
© |
& #169; |
® |
Registered trademarks |
® |
& #174; |
X |
Multiplication sign |
× |
& #215; |
÷ |
Division Sign |
÷ |
& #247; |
Transfer from http://www.cnblogs.com/xuefuwu/archive/2012/05/06/2486577.html
The role of useunicode=true&characterencoding=utf-8 in MySQL connection URL