The ultimate solution to garbled characters in Linux
Source: Internet
Author: User
The ultimate solution to the garbled Linux system-Linux Enterprise Application-Linux server application information. For details, see the following. When I set up a website in linux, garbled code had plagued me for almost a week and finally solved it.
My experience is that the application must be consistent with the character set (encoding) of the database.
Specifically, if you want to use gb2312 encoding, make sure that each jsp file is stored in gb2312 encoding (you can select gb2312 encoding when saving the file ), in addition, the file header must also be defined. For databases, encoding must be defined when a database is created, for example, create database mysql default character set gb2312 collate gb2312_chinese_ci. The last step is to connect to the data, add the following code to the relevant file:
UseUnicode = true & characterEncoding = gb2312.
In linux, you do not need to select gb2312. I use utf8. Of course, you must follow the above steps to set it. No garbled code will appear! Your personal preferences!
I tried a lot of methods before, such as changing the system font in the/etc/sysconfig/i18n file, in the/etc/my. in cnf, add the following statement default-character-set = gb2312 after the [mysqld] field. I don't think it is necessary.
The above steps seem simple, but my failure lessons are also my success experiences. Now I want to share with you what you have learned after reading it. If you don't stick to it, it's just your kindness!
Forget, there is another key point: jdbc must use a suitable version. I used 3.0.9 before, but I found that it was not enough. Later I used 3.0.16 and it was okay.
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:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.