Solution to the problem of web server program running in disorder

Time:2019-11-30

Use PHP to define the default language of PHP

In php.ini:
default_charset = “gb2312”

Output Chinese in web page

Java uses the code “iso-8859-1” in network transmission, so it needs to be converted when outputting, such as:
String STR = “Chinese”;
str=new String(str.getBytes(“GB2312″),”8859_1”);
However, if the code used in compiling the program is “GB2312”, and the program is run on the Chinese platform, this problem will not occur. It must be noted.

Read Chinese from parameters

This is exactly the opposite of the output in the web page, such as:
str=new String(str.getBytes(“8859_1″),”GB2312”);

Chinese problems in operation DB

A simpler way is to set “area” to “English (US)” in “control panel”. If there will be garbled code, you can also set as follows:
When taking Chinese: STR = new string (str.getbytes (“GB2312”));
Input Chinese to DB: STR = new string (str.getbytes (“iso-8859-1”);

Chinese solution in jsp:

In control panel, set area to English (USA)
Add:

<%@ page contentType=text/html; charset=GBK %>
If the normal display is not available, the following conversion shall be performed:
For example: name = new string (name. GetBytes (“iso-8859-1”), “GBK”);
There will be no Chinese problem

Chinese question in asp.net:

Add the following code to the congfig file to solve the problem of passing Chinese parameters between pages,
<globalization fileEncoding=”gb2312″ requestEncoding=”gb2312″ responseEncoding=”gb2312″ culture=”zh-CN”/>