Summary of Web Ajax application internationalization and garbled characters

Source: Internet
Author: User
I can see that N people on csdn asked the same question, Ajax garbled characters, and so on. I 'd like to make a summary. If not, please advise.

The environment I am talking about is Asp.net web applications, and other Web development applications are a truth.

Follow these steps to develop an international and multilingual web application:

1. First of all your project's stuff (mainly refers to various files, including the backgroundCode, Resource files, etc.) use UTF-8 file encoding. This step solves the file encoding problem (ensure that your file is actually applied or converted to UTF-8 encoding, use a conversion tool or advanced storage options of)

2. set charset to UTF-8 (charset can be specified for Link and script at the same time) in all your web page Meta, so that the request you send from the page (declare a request that is not an Ajax request, ajax requests are processed separately). For example, the post requests generated by clicking the button are transmitted in UTF-8.

3. after step 2, the server is required to know that the HTTP request sent by your client is encoded with UTF-8 by default, you do not need to perform UTF-8 decoding on the server to retrieve the parameters in the request. This is used in Asp.net. config notifies the Asp.net processing engine of the web server, in which system. add the following configurations to the Web:
<Globalization requestencoding = "UTF-8" responseencoding = "UTF-8" fileencoding = "UTF-8 "......

4. to solve the problem of Ajax Request Encoding, Ajax does not use the default encoding to transmit data. Instead, it uses UTF-8 encoding in a unified way with our system, this should be set based on the specific JS lib you are using. UTF-8 is used by default in prototype (if not, you can add encoding: 'utf-8' with the options of Ajax '), the default value of dojo is ANSI. You can set it as needed. You can specify the following parameters for users who write Ajax requests in bare mode:
Request. setRequestHeader ('content-type', 'application/X-WWW-form-urlencoded; charset = UTF-8 ');

5. Note that for get requests (or those involving URL-based parameters), the transmitted parameters must be processed by the encodeuricomponent method first.

Let's sum up these five points. If you have any questions, let's talk about them again. If you have any summary omissions, please correct them. The problem of multi-speech, Ajax, and common requests in our project has been completely solved.

// Supplement
In addition, if a page with a JS application (most of them are) encounters a strange error (for example, an application with two similar pages but one of them is an error ), check the encoding problems, such as the encoding of HTML web pages (the Page code selected on the browser) and the encoding of the JS files applied. If any problems are found, you can modify the errors according to the above rules. Otherwise, this situation is very time-consuming!

// 2007-10-12
Another very time-consuming problem is the CSS performance issue caused by the doctype mark of the HTML page. For example, two very similar pages use the same CSS but the performance is inconsistent, you can try to change the doctype mark.

Related Article

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.