转换编码 Dim fileOldName As String = "FlashChatData632313853411508100.asp" Dim fileNewName As String = "FlashChatData632313853411508100_2.asp" fileOldName = Server.MapPath(Request.ApplicationPath & "/" & fileOldName) fileNewName = Server.MapPath(Request.ApplicationPath & "/" & fileNewName) Dim SR As System.IO.StreamReader = New System.IO.StreamReader(fileOldName) Dim sw As System.IO.StreamWriter = New StreamWriter(fileNewName, False, System.Text.Encoding.Default) sw.Write(SR.ReadToEnd()) SR.Close() sw.Close()
Dim sw As System.IO.StreamWriter = New StreamWriter(fileNewName, False, New UnicodeEncoding)可以存储UnicodeEncode
asp中用gb2312对吗??他们的长度差1.5倍??我是用asp 生成一个xml文件,flash调用这个xml文件,就能生成正确的图表。症状是:如果我用.net来生成这个文件,在asp中占两个汉字的“北京”,在.net生成的xml文件中看起来也是“北京”,但flash从此文件中读出xml后,显示出来的是占三个汉字的乱码。我想问题是在于文件的编码格式上,在asp一个汉字节两个字节,在.net上却占了三个字节,对吗?如何解决??
将数据读出来写到一个文件中,关键是把参数设为:System.Text.Encoding.Default
我想死也没有想到是Default!!!我曾用UTF-8,UTF-7,Unicode等试过,后来没有看到 ANSI,就用Default,成功!!! smw = New StreamWriter(strPFileName, False, System.Text.Encoding.Default) 'Default 表示系统默认编码,在此处表示ANSI编码
smw.WriteLine(xml) '写入文件~~~~~
Dim fileOldName As String = "FlashChatData632313853411508100.asp"
Dim fileNewName As String = "FlashChatData632313853411508100_2.asp"
fileOldName = Server.MapPath(Request.ApplicationPath & "/" & fileOldName)
fileNewName = Server.MapPath(Request.ApplicationPath & "/" & fileNewName) Dim SR As System.IO.StreamReader = New System.IO.StreamReader(fileOldName)
Dim sw As System.IO.StreamWriter = New StreamWriter(fileNewName, False, System.Text.Encoding.Default) sw.Write(SR.ReadToEnd())
SR.Close()
sw.Close()