0

VBScript does delivers an "Illegal Argument" message when trying to write the text shown below to file using the following code. If I change resultStr to some test text, it works. What could be the problem?

Set resFile = fs.CreateTextfile(resFilePath, true)
resFile.write resultStr
resFile.close

Contents of resultStr:

Sample

1 Answers1

1

Your string looks like it contains non-ASCII characters. You need to pass an extra True argument to CreateTextfile to open the text file using a Unicode encoding (probably UTF-16 on Windows).

If you want to write UTF-8 to the file, see Writing UTF8 text to file.

Community
  • 1
  • 1
nneonneo
  • 171,345
  • 36
  • 312
  • 383