Encoding a string to a file in UTF-8
I have in my program built up a string forming an XML document. This document then needs to be saved to a file. See Code below.
This generates the XML file fine except when i want to use an extended chatacter, such as é in the data.
I need to therefore when saving the string encode it in UTF-8.
I'm using VBA for Microsoft Office 2000, one of the constraints laid down from upon high.
Thanks for any help you can give me.
Code:
Private Sub cmdGenerateXML_Click()
Dim sString As String
Dim iFile As Integer
'Can XML be geneated?(i.e. has it been loaded)
gbGenerationAllowed = True
If gbGenerationAllowed Then
'Form the main XML string by calling each of the seperate files
sString = "<CEVOLUTION_CONFIG>"
sString = sString + genSystemConfigObjectXML()
sString = sString + genContextObjectsXML()
sString = sString + genUserConfigObjectsXML()
sString = sString + genContextSettingsXML()
sString = sString + genPickListXML()
sString = sString + "</CEVOLUTION_CONFIG>"
'Write the string out
iFile = FreeFile()
Open path_to_xml & "\A.XML" For Output As #iFile
Print #iFile, sString
Close #iFile
MsgBox ("XML Generation Successful")
Application.Worksheets("MAIN").Activate
Else
MsgBox ("Cannot Generate XML")
Application.Worksheets("MAIN").Activate
End If
End Sub