Role of the useUnicodetrueamp; amp; characterEncodingUTF-8 in the mysql connection url bitsCN.com
Functions of useUnicode = true & characterEncoding = UTF-8 in mysql connection url
When we connect to the mysql database, we usually add useUnicode = true & characterEncoding = UTF-8 after the url, but what do you want to add?
The added function is to specify the encoding and decoding formats of characters.
For example, the mysql database uses gbk encoding, while the project database uses UTF-8 encoding. At this time, if useUnicode = true & characterEncoding = UTF-8 is added, the role has the following two aspects:
1. when saving data:
When the database stores project data, it first decodes the data into bytecode in UTF-8 format, and then stores the decoded bytecode into the database again using GBK encoding.
2. Data Retrieval:
When retrieving data from the database, the database first decodes the data in the database in GBK format into bytecode, and then decodes the decoded bytecode and re-encodes the data in UTF-8 format, finally, return the data to the client.
Note: When configuring the database URL in the xml configuration file, use the & Escape character, that is &
For example:
Common special characters in HTML:
Character Entities)
Display result description Entity Name Entity Number
Display a space
<Less than <
>>>>
& Symbol &&
"Double quotation marks ""
Character Entities)
Display result description Entity Name Entity Number
? Copyright©©
? Registered trademark®®
× Multiplication number ×
& Pide; Division number & pide; Division
BitsCN.com