ASP tips: Using International Web sites

Source: Internet
Author: User
Tags character set http request locale
Web| Tips | One advantage of a site posting messages on the Internet or on an Intranet is that you can build an internationalized Web site that users can access from different countries (regions). Users can request a Web page that has been localized to the local language and read it using a localized version of the browser. When you build a Web site that contains multiple language pages, you need to convert the strings that are passed between the browser and the Web server or between ASP scripts and ActiveX components. For example, if a Japanese browser sends a table or query string value in an HTTP request, this string must be converted from the Japanese character set in the browser to the character set that the ASP uses to process the script.





if all pages on the Web site are written with the default character set used by the Web server, the ASP will automatically convert. However, if the Web page is written in a different character set, you must use an ASP command to indicate how to convert the string. For example, if your site has both a Web page for the Japanese character set and a Web page for the Chinese character set, you must indicate the character set used by the ASP to process a particular page.





ASP also provides commands to support cultural practices in different regions, such as currency, time, and date formats. As with string conversion commands, use the live command if your script does not use the default locale of the WEB server.





set string Conversion code page

The
code page is an internal table that the operating system uses to map symbols (letters, numbers, and punctuation marks) to character numbers. Different code pages support the character set used by different countries (regions). Code pages use a number reference, for example, code page 932 represents the Japanese character set, and code page 950 represents the traditional Chinese character set.





Active Server Pages and the ActiveX scripting engine use Unicode internally, which is a 16-bit fixed-length character encoding standard. If all the pages you write use the WEB server's default code page, the ASP will automatically convert the strings. If your script does not use the WEB server's default code page, you should indicate the code page used so that the string can be converted correctly when passed between the ASP and the scripting engine. Alternatively, you can specify code pages for strings that are passed between the browser and script or ActiveX components and scripts.





To specify a code page for an ASP page, you can use the CODEPAGE directive. For example, to set the Japanese code page, you can use the following directive:





<%@ codepage= 932%>


when ASP processes the content and script for this page, it uses the code page that you specify to decide how to convert characters from your script to Unicode from the script's character set. For example, a value that represents the letter "a" in ANSI will be converted to a different value that represents the letter "a" in Unicode.





Active Server Pages assumes that the code page for a string passed between the server and the browser or between script and ActiveX components is the same as the code page you set for the script. To specify a different code page, you can override the CodePage setting by setting the Session.CodePage property. For example, you use JIS to write scripts, but you want to respond to client programs that use UTF-8 (JIS and UTF-8 are two different character encodings of the standard Japanese character set).





Session.CodePage defaults to the value of the CodePage directive; The setting for this property overrides the current CodePage setting. For example, to change the code page to traditional Chinese, you can use the following command:





<% session.codepage = 950%>


If you are only temporarily changing the code page of a part of the script, then make sure to set the Session.CodePage to its original value. The following script shows how to temporarily change the code page:





<!--Welcome to me home page in Japanese, code page 932--! >


<%@ CodePage = 932%>


...


<% session ("originalcodepage") = Session.CodePage%>


<!--look up name in Chinese, code page 950--! >


<% session.codepage = 950%>


<% Sender = Readmailheader ("Sender")%>


<% Found = findfriend ("Sender")%>


<!--Restore The original code page--! >


<% Session.CodePage = Session ("Originalcodepage")%>


<% If Found = = TRUE


Replywithpersonalizedform ()


Else


Replywithbusinessform ()


%>


Set up field identification


locale is a set of user preference information related to the language of the user. The field determines how to format dates and times, items, how to sort alphabetically, and how to compare strings. The field ID (LCID) is a 32-bit value that uniquely defines the field. If you do not specify a different locale for the script, the ASP uses the default locale for the WEB server.





to set up the field identification for an ASP page, you can use the LCID directive. For example, to set up a Japanese locale, you can use the following field IDs:





<%@ LCID = 1041%>

The
LCID instruction tells the ASP to write the scene for the script. You can use the Session.LCID property if you want to change the input or output field of a script. For example, to set the locale to standard French, you can use the following command:





<% session.lcid = 1036%>


The default setting for Session.LCID is the setting of the LCID directive. Setting the Session.LCID value in the script overrides the default setting.





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.