如何通过 VBScript 将非拉丁字符保存在文本文件中?

How can I save non-Latin characters in a text file via VBScript?

汉字无法通过 VBScript 保存在文本文件中。

VBScript在中文名称为视窗的文件夹中。该脚本将创建一个文本文件,其中将显示当前工作目录。中文字符不能保存在文件中。 Windows 脚本主持人说 "Error: Invalid procedure call or argument"。如果文件夹名称是英文,则不会出现此错误。

Path = CreateObject("WScript.Shell").CurrentDirectory
Set objFSO  = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(Path & "\Testing.txt", 8, True)    
objFile.WriteLine Path
objFile.close

VBScript是否可以保存包含汉字的文件路径?

方法 openTextFile 有另一个可选参数 - format。它的值默认为 0,以 ASCII 格式打开文件。要保存文件中的汉字,可以通过指定参数format = -1的值以UNICODE格式打开文件。这里是Reference.

objFso.openTextFile(path,8, true, -1)             '-1 = TriStateTrue = Opens the file as Unicode
path = split(wscript.scriptFullName, wscript.scriptname)(0) & "Testing.txt"
set objFso = createObject("scripting.filesystemobject")
set objFile = objFso.openTextFile(path,8, true, -1)
objFile.write path
objFile.Close
set objFile = Nothing
set objFso = Nothing