For some background, please see knowledge base article:
ToXml() always returns the standard encoding for strings of the programming language used, i.e. in C++ it would be the local code page, and for C++ built as UNICODE and for other languages (C#, VB.Net, Java, VB6) it would be Unicode. This is so the data can be manipulated as strings within your code.
ToXmlFile() and ToXmlStream() deal with Binary Data in the encoding specified for the XML Document, which you can pass as a parameter.
Hope this helps.