熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

asp 把UTF8轉換GB2312代碼

2022-06-13   來源: .NET編程 

  個人代碼風格注釋(變量名中第一個小寫字母表表示變量類型)
i:為Integer型;
s:為String;
Function UUTF(Byval a_iNum)
Dim sResultsUTF
Dim iTempiHexNumi

  iHexNum = Trim(a_iNum)

  If iHexNum = “” Then
Exit Function
End If

  sResult = “”

  If (iHexNum < ) Then
sResult = sResult & iHexNum
ElseIf (iHexNum < ) Then
sResult = ChrB(&H + (iHexNum And &HF))
iHexNum = iHexNum &H
sResult = ChrB(&HC + (iHexNum And &HF)) & sResult
ElseIf (iHexNum < ) Then
sResult = ChrB(&H + (iHexNum And &HF))
iHexNum = iHexNum &H
sResult = ChrB(&H + (iHexNum And &HF)) & sResult
iHexNum = iHexNum &H
sResult = ChrB(&HE + (iHexNum And &HF)) & sResult
End If

  UUTF = sResult
End Function

  Function GBUTF(Byval a_sStr)
Dim sGBsResultsTemp
Dim iLeniUnicodeiTempi

  sGB = Trim(a_sStr)
iLen = Len(sGB)
For i = To iLen
sTemp = Mid(sGBi)
iTemp = Asc(sTemp)

  If (iTemp> OR iTemp<) Then
iUnicode = AscW(sTemp)
If iUnicode< Then
iUnicode = iUnicode +
End If
Else
iUnicode = iTemp
End If

  sResult = sResult & UUTF(iUnicode)
Next

  GBUTF = sResult
End Function

  調用方法
ResponseBinaryWrite(GBUTF(“中國人”))


From:http://tw.wingwit.com/Article/program/net/201311/14206.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.