VB.NET中gbk转为utf-8(未测试)

VB.NET | 2017-07-15 00:19:46 | 阅读 1938 次 | 评论(0)
从网上找的,没测试有效性,先收藏了,说不定哪天用到
    Private Function StringAsUtf8Bytes(ByVal str As String) As String
        Dim utf8, gbk As System.Text.Encoding
        utf8 = System.Text.Encoding.GetEncoding("utf-8")
        gbk = System.Text.Encoding.GetEncoding("gbk")
        Dim bytes() As Byte = gbk.GetBytes(str)
        bytes = System.Text.Encoding.Convert(gbk, utf8, bytes)
        Return utf8.GetString(bytes)
    End Function
文章评论,共0条
游客请输入验证码
浏览1893794次
文章归档
最新评论
  • 神犇dengyuhy:语文很好
  • 猫云:学习 学习