Save xml-file with OpenTextFile and UTF-8 encoding

Dear All,
I am working with InfoPath and got a VBscript that creates an XML-file with the following commands:
Set oFS = CreateObject("Scripting.FileSystemObject")
Set objXMLFile = oFS.OpenTextFile(filename,2,true,TristateFalse)
objXMLFile.Write(XDocument.DOM.xml)
objXMLFile.Close

The problem is that the xml-file includes data with "umlauts" and can not be parsed in InfoPath as it is. If I open the xml-file with notepad and save it again with the encoding utf-8 it is working perfect.

Is there a way to create the file with the script that is saved with the UTF-8 encoding?

Please ask if anything is not clear.

Thanks in advance and greetings
Marcus
Marcus_KuhnAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
spinzr0Connect With a Mentor Commented:
Yes, just use this to create the file:

Set oFS = CreateObject("Scripting.FileSystemObject")
Set objXMLFile = oFS.CreateTextFile(filename,True,True)
objXMLFile.Write(XDocument.DOM.xml)
objXMLFile.Close
0
 
Marcus_KuhnAuthor Commented:
Thanks for the answer. I am not at work at the moment so I can not test it but are you sure that this works, because I already tried out all three "Tristate"-options and it did not work.

I will test it tomorrow. Thanks
0
 
spinzr0Commented:
I use this all the time to handle unicode characters for our Asian offices.  It should work for you as well.  If not, I can definitely dig deper.
0
 
Marcus_KuhnAuthor Commented:
It worked. Thank you very much.
0
All Courses

From novice to tech pro — start learning today.