The illusion of coding-general Linux technology-Linux programming and kernel information. The following is a detailed description. I am used to using the linux + tomcat + jdk + mysql platform for web development. garbled code is a common problem and often bothers me. In such an open environment, garbled characters are usually concentrated in these steps. Underlying linux encoding, intermediate server component encoding, database encoding, and application code. Generally, linux provides many encoding schemes, including UTF-8 and general Chinese encoding classes such as GBK and GB18030. The server components in the middle are similar to tomcat and there will be Encoding Problems, especially on the URLencoding of tomcat, there are multiple encoding options. mysql should not talk about a bunch of encoding character sets, connection character sets, client character sets, and record result character sets, application code is mainly determined by java applications. For example, we use the conversion encoding method new String (. getByties (),""). So many codes need to be considered. There are sometimes some influences between various encodings and you have to consider them.
The encoding of the operating system is the most basic encoding. The real cause of the garbled code that we don't feel in many cases is the OS encoding. For example, some time ago, when I installed the mysqlcc client on linux, I found that it was all messy and thought it was the database and the software itself (the software itself can be considered as the encoding problem of the application) but eventually found that the problem is the operating system problem, when changing the operating system encoding to GB18030 Simplified Chinese encoding and application (mysqlcc) this encoding is consistent with that of the database (I used latin1 encoding to store GBK Simplified Chinese), and garbled characters no longer appear. Garbled characters may occur after the sqlyog client is installed. I determined that this is not the reason for the operating system and database. The reason is that sqlyog of the application must adopt UTF-8 encoding, therefore, garbled characters must be found in all databases of GBK and latin1.
The encoding of the server's intermediate components may also cause garbled characters. For example, if you try to pass a Chinese character through a URL on the tomcat server, it will be garbled if you do not set it, set server. the URLencoding encoding in xml is used to control the parameter encoding passed on the server.
The encoding on the application is a relatively intuitive encoding form. In java Development code, we can control the encoding of each character in the application using methods such as new String, this garbled code is the easiest and most intuitive solution.
Mysql encoding is the most troublesome. Since Mysql was followed by international language support, various encoding problems have not been stopped. Since mysql has more refined control over character sets, but these character sets are the first thing we should consider when encountering Encoding Problems -- character-set-client character-set-connection character-set-result. The articles on Mysql encoding are everywhere. I will not repeat them here.
Every garbled problem must be analyzed to find out which link has a problem, and there will be an impact between different links. If I encounter a problem today, I can explain this situation: A piece of program that runs well on my local Federo8 system, a problem occurs on the server, I converted various encoding in java but it never solved the problem, and finally found that the server encoding is ISO-8859-1, I am a local GB18030, which is the key to the problem.
Gibberish problems can be encountered in various open-source environments, such as LAMP. Even if you use eclipse, there will be gibberish problems. I envy Microsoft developers here, they have a unified platform from OS to server IIS to database SQLSERVER to application ASP /.. NET, which minimizes the possibility of garbled code. But it is less fun for programmers to solve problems.
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.