How to create XML files in UTF-8?
It seems that windows always produces UTF-16LE files, but I need it to produce in UTF-8.
Example code I've already tried:
PBDOM_Document xml_doc
PBDOM_ProcessingInstruction xml_process
PBDOM_Element xml_root
constant string root_name = "root_node"
try
xml_doc = create PBDOM_Document
xml_doc.newdocument(root_name)
xml_process = create PBDOM_ProcessingInstruction
xml_process.setname("xml")
xml_process.setvalue("version", "1.0")
xml_process.setvalue("encoding", "utf-8")
// it seems that windows always produce utf16 files
xml_doc.addcontent(xml_process)
destroy xml_process
xml_root = xml_doc.getrootelement()
// (....)
xml_doc.savedocument("foobar.xml")
destroy xml_root
destroy xml_doc
CATCH ( PBDOM_Exception pbde )
MessageBox( "PBDOM Exception",pbde.getMessage() )
CATCH ( PBXRuntimeError re )
MessageBox( "PBNI Exception",re.getMessage() )
end try
I use Powerbuilder 2021 Build 1311
;) grateful
Just a warning: Powerbuilder is pretty unclear on how much heap memory you have available for for exampe a FileWriteEx(). The other day it blew up on writing only 50 MB. Probably it will behave better if you have a 64 bit executable (which I don't).
regards
You are right.
Andreas.