关于文字编码的问题

digitalghost 2003-08-30 02:19:17
今日写一个FTP客户端的时候,发现将用套结子传回来的Byte[]进行System.Text.Encoding.ASCII.toString()操作的时候无法将Byte[]内的内容正常还原成中文,都是乱码,并且用其他的解码方式都无法正常显示,请问各位如何解决这个问题呢?
...全文
32 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-08-30
  • 打赏
  • 举报
回复
there might be some magic bytes at the start of the file you can use to identify the encoding, but normally, you just save the bytes
digitalghost 2003-08-30
  • 打赏
  • 举报
回复
实在是太感谢您了!
小弟斗胆再问一句,如果你不知道那个FTP用的是什么方式的文字编码,那么怎么判断啊!
saucer 2003-08-30
  • 打赏
  • 举报
回复
try

string s = System.Text.Encoding.GetEncoding("GB2312").GetString(YourByteArray);

110,526

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧