Use PHP to define the default PHP language.
In PHP. ini:
Default_charset = "gb2312"
Output Chinese characters on the webpage
Java is used in network transmission encoding is "ISO-8859-1", so in the output need to be converted, such:
String STR = "Chinese ";
STR = new string (Str. getbytes ("gb2312"), "8859_1 ");
However, ifProgramThe encoding used is "gb2312" and the program runs on the Chinese platform.
Read Chinese from Parameters
This is exactly the opposite of the output in the webpage:
STR = new string (Str. getbytes ("8859_1"), "gb2312 ");
Chinese problems in dB operations
A simple method is to set "region" to "English (USA)" in "control plane )". If garbled characters still appear, you can perform the following settings:
When retrieving Chinese characters: Str = new string (Str. getbytes ("gb2312 "));
Input Chinese characters to DB: Str = new string (Str. getbytes ("ISO-8859-1 "));
Solutions for Chinese in JSP:
In "control plane", set "region" to "English (USA )".
Add:
<% @ Page contenttype = text/html; charset = GBK %>
If not, perform the following conversion:
For example: Name = new string (name. getbytes ("ISO-8859-1"), "GBK ");
There will be no Chinese problems.
Chinese problems in ASP. NET:
Add the followingCodeTo solve the problem of passing the value as a Chinese parameter between pages,
<Globalization fileencoding = "gb2312" requestencoding = "gb2312" responseencoding = "gb2312" Culture = "ZH-CN"/>