ASP Code conversion (garbled problem resolution)

Source: Internet
Author: User

ASP Code conversion (garbled problem resolution)

The conversion function is called before output to encode the conversion, can solve the garbled problem.

Note, "& Parameters &" for the ASP connector, many of which are directly called database table fields, the actual use please modify and then Debug.

<!--GB to Unicode---Convert GB encoded text to Unicode encoded text--
<%function Conversion (str) for I=1 to Len (str) str_one=mid (str,i,1) str_unicode=st R_UNICODE&AMP;CHR (STR_UNICODE=STR_UNICODE&AMP;CHR) STR_UNICODE=STR_UNICODE&AMP;CHR (12 0) str_unicode=str_unicode& Hex (AscW (Str_one)) STR_UNICODE=STR_UNICODE&AMP;CHR (59) Next Conversion = Str_unicodeend function%> <% Dim html HTML = "<table width= ' 600px ' border= ' 1px ' >< tr><th colspan= ' 2 ' align= ' center ' > ' &conversion (User survey) & &LT;/TH&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD Width= ' 200px ' > ' &conversion ("Company name") & "</td><td>" &conversion ("" &company& "") & "</td></tr><tr><td>" &conversion ("Company Address") & "</td><td>" & Conversion ("&addr&") & "</td></tr><tr><td>" &conversion ("department") & "< /td><td> "&conversion (" "&dep&" ") &" </td></tr&Gt;<tr><td> "&conversion (" Contacts ") &" </td><td> "&conversion (" "&contacts& "") & "</td></tr><tr><td>" &conversion ("Contact") & "</td><td>" & Conversion ("&phone&") & "</td></tr><tr><td>" &conversion ("Problem description") & " </td><td> "&conversion (" "&qs_inf&") & "</td></tr><tr><td>" &conversion ("Answer submit") & "</td><td>" &conversion ("&qs_wt&") & "</td></ Tr></table> "%>

Other: GB to utf8--convert GB encoded text to UTF8 encoded text

<!--GB utf8--convert GB encoded text to UTF8 encoded text--><%function toUTF8 (szinput) Dim wch, Uch, Szret Dim x Dim NAsc, NASC2,  NASC3 ' If the input parameter is empty, the Exit function if Szinput = "then toUTF8 = szinput Exit Function End If ' Start converting for X        = 1 to Len (szinput) ' uses the mid function to split GB encoded text WCH = Mid (Szinput, X, 1) ' uses the ASCW function to return Unicode character codes for each GB encoded text ' NOTE: The ASC function returns the ANSI character code, note the difference NASC = ASCW (WCH) if NASC < 0 Then nAsc = nAsc + 65536 If (NAsc an                D &hff80) = 0 Then Szret = szret & WCh Else If (NASC and &hf000) = 0 Then Uch = "%" & Hex (((NASC \ 2 ^ 6) or &hc0) & Hex (NASC and &h3f Or &h80) Szret = Szret & Uch Else ' GB encoded text Unicode character code between 0800-FFFF with a three-byte stencil uch = "%" & Hex ( (NASC \ 2 ^ 12)          or &AMP;HE0) & "%" & _ Hex ((NASC \ 2 ^ 6) and &h3f or &h80) & "%" & _                  Hex (NASC and &h3f Or &h80) Szret = szret & uch End If End I F Next toUTF8 = Szretend function%>

  

Finish

ASP Code conversion (garbled problem resolution)

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.