QTP脚本中的字符变成了乱码
各位:我用附件中的vbs执行修改了qtp的脚本后,脚本中的中文字符变成了乱码?有人遇到过该问题吗? 文件编码的关系,最后保存的默认是ANSI , 脚本原来的是 UTF-8
所以中文就乱了 skyzhu :
我知道relpace脚本重写了qtp脚本同时修改了编码格式,那我该怎么修改才能保持编码是UTF-8 呢? 用 CreateObject("Adodb.Stream")
读写转换编码试试 读写转换编码?skyzhu, 你能具体说一下工作原理吗?我这里没有什么头绪 例子是gb2312读取,utf-8写入,自己看着改吧
File = "D:\123.txt"
Code1 = "gb2312"
Code2 = "utf-8"
WriteToFile File, ReadFile(File, Code1), Code2
Function ReadFile(Filepath, CharSet)
Dim Str
Set stm = CreateObject("Adodb.Stream")
stm.Type = 2
stm.mode = 3
stm.charset = CharSet
stm.Open
stm.loadfromfile Filepath
Str = stm.readtext
stm.Close
Set stm = Nothing
ReadFile = Str
End Function
Function WriteToFile (Filepath, Str, CharSet)
Set stm = CreateObject("Adodb.Stream")
stm.Type = 2
stm.mode = 3
stm.charset = CharSet
stm.Open
stm.WriteText Str
stm.SaveToFile Filepath, 2
stm.flush
stm.Close
Set stm = Nothing
End Function
页:
[1]