被放逐 发表于 2008-6-21 11:00

[求助]在VS中,用VB编写一段写入txt文档的语句,txt中出现乱码?

Dim fs As New FileStream("D:/file.txt, FileMode.OpenOrCreate)
Dim sw As StreamWriter = New StreamWriter(fs)
sw.WriteLine("记录")
sw.Close()

发现如果是英文和数字就显示正常,但中文就会出现类似繁体字的乱码,怎么回事?
而且有时候会正常,有时候又不正常

vinceQ 发表于 2008-6-30 12:10

这是中文编码问题.

tntzwc 发表于 2008-6-30 17:01

实例化类StreamWriter的时候,可以选择编码

Viviwei 发表于 2008-7-2 16:46

In IO operation can be encoded choice, generally GB2312, such as the code: System.Text.Encoding.GetEncoding ( "GB2312")

tntzwc 发表于 2008-7-3 08:39

super man

页: [1]

编程论坛