+ -
当前位置:首页 → 问答吧 → 显示在网页地址栏的中文怎么才能转换啊?

显示在网页地址栏的中文怎么才能转换啊?

时间:2011-09-15

来源:互联网

在一个地址栏里的“%D3%CE%CF%B7”这个字符,表示中文“游戏”,那我应该如何把“游戏”这个词通过VB转换成“%D3%CE%CF%B7”呢,还有其他中文又是该如何转换呢?谢谢!

作者: penguinhzf   发布时间: 2011-09-15

参阅这个:
VB code

ption Explicit

Private Sub Command1_Click()
    Dim bArr() As Byte
    Dim strByte() As String
    Dim sMe As String
    Dim intP As Integer
    If Text2.Text = "" Then Exit Sub
    strByte = Split(Text2.Text)
    For intP = LBound(strByte) To UBound(strByte)
        strByte(intP) = CStr(Val("&H" & strByte(intP)))
    Next intP
    ReDim bArr(UBound(strByte) - LBound(strByte) + 1)
    For intP = LBound(strByte) To UBound(strByte)
        bArr(intP) = Val(strByte(intP))
    Next intP
    sMe = StrConv(bArr, vbUnicode)
    Text1.Text = sMe
End Sub

Private Sub Command2_Click()
    Dim intP As Integer
    Dim uniByte() As Byte
    If Text1.Text = "" Then Exit Sub
    uniByte = StrConv(Text1.Text, vbFromUnicode)
    Text2.Text = ""
    For intP = LBound(uniByte) To UBound(uniByte)
        Text2.Text = Text2.Text & Right("00" & Hex(uniByte(intP)), 2) & " "
    Next intP
    Text2.Text = Left(Text2.Text, Len(Text2.Text) - 1)
End Sub

Private Sub Form_Load()
    Text1.Text = "游戏"
End Sub



D3 CE是 游 的区位码。至于%号,那可能是各个字节之间的分割而已。

作者: Veron_04   发布时间: 2011-09-15

作者: Veron_04   发布时间: 2011-09-15

热门下载

更多