Function SaveTextToFile(FileFullPath As String, _ sText As String, Optional Overwrite As Boolean = False) As _ BooleanOn Error GoTo ErrorHandlerDim iFileNumber As IntegeriFileNumber = FreeFileIf Overwrite Then Open FileFullPath For Output As #iFileNumberElse Open FileFullPath For Append As #iFileNumberEnd IfPrint #iFileNumber, sTextSaveTextToFile = TrueErrorHandler:Close #iFileNumberEnd Function
The above function saves the String contained in the variable sText in the File given in the variable FileFullPath.
My problem is that my String contains also characters in other languages and I want to save it in a file with the extension .xml so it opens in Excel.
In the attached .zip file there are 2 files. "book1.xml" and "book2.xml".
book1.xml can be opened in an XML editor
book2.xml has been made using the aforementioned function and can not be opened in an XML editor since there is an encoding error
book1.xml is correct UTF-8
book2.xml made using the aforementioned function is defnitely saved as a one byte encoded file, and hex C5 et al. are illegal UTF-8, I am not sure it is ANSI, but it is a single byte encoding
Is it possible to make some modifications so the above mentioned function saves the multi-language string as an .xml UTF-8 (2 byte) file so it is compatible with other languages and opens with Excel or .xml editors?