Convert Chinese to Unicode convert Unicode to normal text _ Application Tips

Source: Internet
Author: User
Tags chr gettext

Copy Code code as follows:

'//convert Chinese to Unicode
function urlencoding (Vstrin)

Dim i
Dim strreturn,thischr,innercode,hight8,low8

Strreturn = ""
For i = 1 to Len (Vstrin)
THISCHR = Mid (vstrin,i,1)
If Abs (ASC (THISCHR)) < &AMP;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

'//convert Unicode to normal text
function Bytes2bstr (vIn)
Dim i
Dim Strreturn,thischarcode,nextcharcode

Strreturn = ""
For i = 1 to LenB (vIn)
Thischarcode = AscB (MidB (vin,i,1))
If Thischarcode < &h80 Then
Strreturn = Strreturn & Chr (Thischarcode)
Else
Nextcharcode = AscB (MidB (vin,i+1,1))
Strreturn = Strreturn & Chr (CLng (thischarcode) * &h100 + CInt (nextcharcode))
i = i + 1
End If
Next
Bytes2bstr = Strreturn

End Function

function GetText (O,url)

Dim oreq

On Error Resume Next

If O is Nothing Then
'//Create XMLHTTP Object
Set oreq = CreateObject ("MSXML2. XMLHTTP ")
Else
Set oreq = O
End If

Oreq.open "Get", Url,false
Oreq.send

If Oreq.status = or Oreq.status = 0 Then
GetText = Bytes2bstr (oreq.responsebody)
Else
GetText = ""
End If

End Function

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.