Home  >  Article  >  Backend Development  >  Chinese garbled problem in asp.net

Chinese garbled problem in asp.net

怪我咯
怪我咯Original
2017-03-31 11:41:121605browse

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


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!

Statement:
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