EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How to create a utf-8 encoded TElXMLDOMDocument object

Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.
Posted: 12/05/2013 02:00:30
by Jacob jvandiermen (Standard support level)
Joined: 08/09/2013
Posts: 55

Hello Eldos,

I've one more question about TElXMLDOMDocument.
When you load an utf-8 encoded xml file in a TElXMLDOMDocument object the encoding is standard UTF-16. You get <?xml version="1.0" encoding="UTF-16"?>. How can I change this to <?xml version="1.0" encoding="UTF-8"?>. I tried to load the utf-8 encoded xml file with LoadFromStream(memoryStream,'utf-8', true). I also tried ElXMLDOMDocument.Enc:= TElXMLUTF8Codec.Create;


Posted: 12/05/2013 02:03:40
by Eugene Mayevski (Team)

XML DOM works with UTF-16 encoding internally. You can save the DOM to UTF-8 though. Why would you need UTF-8 DOM in memory?

Sincerely yours
Eugene Mayevski
Posted: 12/05/2013 03:04:15
by Jacob jvandiermen (Standard support level)
Joined: 08/09/2013
Posts: 55

Hello Eugene,

I created a TElXMLDOMDocument object that I use for a xml signature.
The encoding for the signature must must be UTF-8 and not UTF-16 when I save the object to disk.
I noticed that the object is always encoded with UTF-16 when I create it.
I tried several things in order to create a UTF 8 encoded TElXMLDOMDocument object.
I don't need an UTF-8 Dom in memmory.
I just loaded an UTF-8 encoded xml file into the TElXMLDOMDocument object with e memoryStream to see if the object converts the UTF-8 xml into UTF-16.
How can I save the object as a UTF encoded xml file?


Posted: 12/05/2013 03:07:55
by Vsevolod Ievgiienko (Team)


TElXMLDOMDocument.SaveToStream allows to set encoding. Please refer to the documentation for details: https://www.eldos.com/documentation/sb...tream.html
Posted: 12/05/2013 04:27:51
by Jacob jvandiermen (Standard support level)
Joined: 08/09/2013
Posts: 55

Hello Vsevolod,

Thank for the info.
Managed to wirte the object with UTF-8 encoding to disk.


Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.



Topic viewed 1037 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!