Solution to garbled web server program running

Source: Internet
Author: User

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"/>

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.