Automating Test Automation Home Automation Articles Downloads QTP Gotchas Links Books Contact About Site Map
Gotchas - Unicode vs. Ascii
When I get stuck trying to extract data from a web page, my final resort is to get the raw HTML and parse that (see Get Html) Sometimes, to aid debugging, I would save the HTML to a file so I could go back and check it manually. Sometimes the file write failed for no apparent reason. It turns out that most (not all) websites are UTF-8 but QTP handles things internally in Unicode. But the Scripting FileSystemObject OpenTextFile default format is Ansi/Ascii. Most of the time, you get away with it, but now and again, it blows up on you. So when you open a file to write Unicode to, you have to remember to:
Set oFileTo = oFsoTo.OpenTextFile(" (where Const ForWriting = 2, TristateTrue = -1) I also have a function that gets the file encoding here |