Chinese garbled problem in asp.net

怪我咯
Release: 2017-03-31 11:41:12
Original
1542 people have browsed it

The default encoding of asp.net is utf-8. When there is Chinese in the string that is processed interactively with other platforms, garbled characters often appear. This is because other platforms have many Adopt GB2312 encoding. To solve this problem, you can write a function to convert the string first and then process it. The following is the source code of the function:

Imports System.Math
Function URLEncoding(ByVal vstrIn As String)
   Dim strReturn As String
   strReturn = ""
   Dim i As Integer
   Dim ThisChr As String
   Dim innerCode, Hight8, Low8 As Integer
   For i = 1 To vstrIn.Length
       ThisChr = Mid(vstrIn, i, 1)
          If Abs(Asc(ThisChr)) < &HFF Then
                strReturn = strReturn & ThisChr
          Else
                 innerCode = Asc(ThisChr)
           If innerCode < 0 Then
                innerCode = innerCode + &H10000
           End If
           Hight8 = (innerCode And &HFF00) / &HFF
           Low8 = innerCode And &HFF
           strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
      End If
 Next
 URLEncoding = strReturn
End Function
Copy after login


The above is the detailed content of Chinese garbled problem in asp.net. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!