(. 1) on the server side::

  

garbled distortion problem solving various applications
web server to modify the httpd.conf (Redhat placed in the position of /etc /httpd /conf /
Search:
AddDefaultCharset ISO-8859-1
changed to:

#AddDefaultCharset ISO-8859-1

AddDefaultCharset off

The method turns off the sending of the server's default language, so that the language of the web page is determined only by the language set in the html file header.

many articles say that by modifying the default language for the AddDefaultCharset GB2312 GB2312 changed to solve the Chinese garbled, indeed within the GB2312 code page can be displayed, but this is not foolproof. Because when your webpage internal code is not GB2312, even if you specify the correct language on the webpage with the following meta, such as ISO8859-1, it will not be decoded to ISO8859-1, because Apache has already specified GB2312 as the webpage in one step. The language is gone.


(2) good habits, each page of the & lt; head & gt ;; & lt; /head & gt ;; foremost add this line:


<meta http-equiv="Content-Type" content="text/html; charset=gb2312">;

General Chinese version of web editing tools (such as FrontPage, Dreamweaver, etc.) will Automatically add this line.

3, how to solve Chinese file name can not be accessed

Select tool in IE->; internet option->; advanced->; cancel "always in UTF -8 send URL".






The UTF-8 webpage is blank. After adding the metadata identifier to the webpage, you need to manually adjust the encoding to utf-8 to display normally. >

If you are using other popular browsers such as Mozilla, Mozilla Firefox, Sarafi, etc., there is usually no such problem.

Using UTF-8 in the meta of the web page:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> ;;


Before <head>;</head>; put "Content-Type" first, you can solve this problem.

reasons:

IE when parsing web pages are coded in HTML to identify priorities, then HTTP header; and series mozilla browser just right opposite.

In general, many people is the & lt; title & gt ;; & lt; /title & gt ;; at the top, and the title appeared Chinese UTF-8, so that, IE when parsing, it First encounter UTF-8, do not parse down, so you must put the meta before UTF-8 appears, so IE can judge that this page is encoded in UTF-8.


In short:
Whether it is PHP, JSP, ASP or other dynamic webpage scripting language, if you need to make encoding settings, it is best to put it first.

Using php, you can also define the default language of php.


php.ini:

default_charset = "gb2312"


Remove this line and make the above changes. The same is to let the browser automatically select the language according to the charset in the web page header, so that web services in multiple languages ​​can be provided on the same server.


java Chinese garbled solve


turn


in JAVA-based programming, often encounter Chinese characters at And the problems displayed, such as a lot of garbled or question marks.
This is because the default encoding method in JAVA is UNICODE, and the files and DBs that Chinese people usually use are based on GB2312 or BIG5 encoding, so this problem occurs.

1. Output Chinese in the webpage.


JAVA coding used in the transmission network is "ISO-8859-1", so that when the output required for transformation, such as:
String str = "Chinese";
str =new String(str.getBytes("GB2312"),"8859_1");
But if the code used is "GB2312" when compiling the program and running this program on Chinese platform, this problem does not occur Must pay attention.

2, read from Chinese


which coincided with the output parameter in the web page, such as the opposite:
str = new String (str.getBytes ( "8859_1 ")," GB2312 ");

3, Chinese


DB problem in a relatively simple method of operation is: in the" pull control plane "in the The Area is set to English (United States). If there is still garbled characters, you can also set the following:
When taking Chinese: str=new String(str.getBytes("GB2312"));
Enter Chinese into DB: str=new String(str. getBytes ( "ISO-8859-1"));

4, in JSP in Chinese solution:


in the "control plane pull" in the "area "Set to "English (United States)".
In the JSP page to join:
If it still does not display properly, then the following conversion:
such as: name = new String (name.getBytes ( "ISO-8859-1"), "GBK");
There will be no Chinese problems.

CGI? Don't know right?


find the CGI.pm, open it, to find the $ self- & gt ;; charset ( 'ISO-8859-1'); it to $ self- & gt ;; charset ( 'GB2312' );

Copyright © Windows knowledge All Rights Reserved