Beispiel beschädigter Text:VBA-Makro "utf-8" xml schafft, aber nicht wirklich
Prokofjew, Sergej, 1891-1953. | Simfonii︠a︡-kont︠s︡ert
zu
Prokofjew, Sergej, 1891-1953. | Simfonii? A? -Kont? S? Ert
So verwende ich ein VBA-Makro, um zu übertragen, was ursprünglich eine Google-Tabelle zu xml über Excel war. Obwohl ich versucht habe, Excel in erweiterten Optionen zu sagen, um in utf-8 zu speichern, und obwohl das XML in utf 8 gedruckt wird, ist offensichtlich etwas inkorrekt. Dies ist die VBA, die ich glaube, ich habe von Stackoverflow Monaten vor an erster Stelle:
Sub MakeXML(iCaptionRow As Integer, iDataStartRow As Integer, sOutputFileName As String)
Dim Q As String
Q = Chr$(34)
Dim sXML As String
sXML = "<?xml version=" & Q & "1.0" & Q & " encoding=" & Q & "UTF-8" & Q & "?>"
sXML = sXML & "<rows>"
''--determine count of columns
Dim iColCount As Integer
iColCount = 1
While Trim$(Cells(iCaptionRow, iColCount)) > ""
iColCount = iColCount + 1
Wend
Dim iRow As Integer
iRow = iDataStartRow
While Cells(iRow, 1) > ""
sXML = sXML & "<row id=" & Q & iRow & Q & ">"
For icol = 1 To iColCount - 1
sXML = sXML & "<" & Trim$(Cells(iCaptionRow, icol)) & ">"
sXML = sXML & Trim$(Cells(iRow, icol))
sXML = sXML & "</" & Trim$(Cells(iCaptionRow, icol)) & ">"
Next
sXML = sXML & "</row>"
iRow = iRow + 1
Wend
sXML = sXML & "</rows>"
Dim nDestFile As Integer, sText As String
''Close any open text files
Close
''Get the number of the next free text file
nDestFile = FreeFile
''Write the entire file to sText
Open sOutputFileName For Output As #nDestFile
Print #nDestFile, sXML
Close
End Sub
Sub test()
MakeXML 1, 2, "C:\Users\Adam Horvath\Documents\~CODE\prokooutputtitleUTF8.xml"
End Sub
Ich denke, dass die Lösung beinhaltet in einer anderen Art und Weise zu der XML-Datei zu schreiben, aber was auf diese Weise ist, nicht sicher.
Blick in [StrConv] (https://msdn.microsoft.com/en-us/library/office/gg264628.aspx). VBA-Zeichenfolgen sind ANSI, sofern sie nicht konvertiert werden. –