EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How to create a utf-8 encoded TElXMLDOMDocument object

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#27573
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;

Regards,

Jacob
#27574
Posted: 12/05/2013 02:03:40
by Eugene Mayevski (EldoS Corp.)

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
#27575
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?

Regards,

Jacob
#27577
Posted: 12/05/2013 03:07:55
by Vsevolod Ievgiienko (EldoS Corp.)

Hello.

TElXMLDOMDocument.SaveToStream allows to set encoding. Please refer to the documentation for details: https://www.eldos.com/documentation/sb...tream.html
#27578
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.

Regards,

Jacob
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 908 times

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




|

Back to top

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

Got it!