以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  中文转码  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=109325)

--  作者:飞飞
--  发布时间:2017/11/9 15:06:00
--  中文转码
 请问,Unicode的乱码,怎么转成 gb2312的中文?

--  作者:有点甜
--  发布时间:2017/11/9 15:26:00
--  

正常转utf8

 

Dim file As String = "文件.txt"
Dim bytes() As Byte
Dim utf As Encoding = Encoding.GetEncoding("utf-8")  
Dim def As Encoding = Encoding.Default
Bytes = def.GetBytes(file)
Bytes = Encoding.Convert(def, utf, Bytes)  
file = def.GetString(Bytes)  
Output.Show(file)

 

 

utf8转正常

 

Dim file As String = "鏂囦欢.txt"
Dim bytes() As Byte
Dim utf As Encoding = Encoding.GetEncoding("utf-8")  
Dim def As Encoding = Encoding.Default
Bytes = utf.GetBytes(file)
Bytes = Encoding.Convert(utf, def, Bytes)
file = utf.GetString(Bytes)  
Output.Show(file)


--  作者:飞飞
--  发布时间:2017/11/9 15:46:00
--  
以下是引用有点甜在2017/11/9 15:26:00的发言:

正常转utf8

 

Dim file As String = "文件.txt"
Dim bytes() As Byte
Dim utf As Encoding = Encoding.GetEncoding("utf-8")  
Dim def As Encoding = Encoding.Default
Bytes = def.GetBytes(file)
Bytes = Encoding.Convert(def, utf, Bytes)  
file = def.GetString(Bytes)  
Output.Show(file)

 

 

utf8转正常

 

Dim file As String = "鏂囦欢.txt"
Dim bytes() As Byte
Dim utf As Encoding = Encoding.GetEncoding("utf-8")  
Dim def As Encoding = Encoding.Default
Bytes = utf.GetBytes(file)
Bytes = Encoding.Convert(utf, def, Bytes)
file = utf.GetString(Bytes)  
Output.Show(file)

谢谢