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&CHR (STR_UNICODE=STR_UNICODE&CHR) STR_UNICODE=STR_UNICODE&CHR (12 0) str_unicode=str_unicode& Hex (AscW (Str_one)) STR_UNICODE=STR_UNICODE&CHR (59) Next Conversion = Str_unicodeend function%> <% Dim html HTML = "<table width= ' 600px ' border= ' 1px ' >< tr><th colspan= ' 2 ' align= ' center ' > ' &conversion (User survey) & </TH></TR><TR><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≫<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 &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)