VB.Net将字符串转换为字节,然后转换为中文字符

时间:2016-08-09 16:02:47

标签: vb.net character-encoding

如何将字符串转换为字节然后转换为中文字符? 我有以下代码,当然这是错误的我只是如此坚持如何做到这一点:

Public Function convertToChinese(ByVal data As String)
    Dim i As Integer = 0
    Dim j As Integer = 0
    Dim chinese As String = Nothing

    For Each C As Char In data
        Dim s = System.Convert.ToString(AscW(C), 2).PadLeft(8, "0")
        For Each u As Char In s.ToCharArray
            j *= 2
            If C = "1"c Then j += 1
            i += 1
            If i = 8 Then
                i = 0
                chinese &= Char.ConvertFromUtf32(j)
                j = 0
            End If
        Next
    Next
    Return chinese
End Function

0 个答案:

没有答案