Solution: Garbled characters occur when ASP reads Chinese data from the database.

Source: Internet
Author: User
I believe many ASP programmers have encountered this problem. When testing on the local machine and interacting with the database, Chinese characters in the database will become garbled and not English. At the beginning, my solution was to create a virtual directory for the site. However, this is only a solution to the problem, and the problem will occur at any time, when we enjoy the fun of programming, we certainly cannot tolerate such a thing to disturb ~~~, By searching for the cause on the Internet, we finally found the fundamental solution.

I am not saying that Chinese characters may contain garbled characters, but English letters may not? First, we should guess whether the encoding is correct! The default internal encoding of ASP is Unicode. When the page is not specified, garbled characters may occur sometimes (why is it strange sometimes? I hope to explain it in the comment bar ), the solution is:Add <% @ codePage = 936%> In The Connection database Conn. asp file,You can display Chinese characters normally.

PS:
<% @ CodePage = 936%> Simplified Chinese
<% @ CodePage = 950%> traditional Chinese
<% @ CodePage = 65001%> UTF-8797000024

CodePage specifies the encoding used by IIS to read passed strings (such as form submission and address bar transfer ).
It also specifies the encoding for converting all text variables from Unicode,
It also specifies the Unicode conversion encoding of the data retrieved from the database.

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.