tinyxml2 icon indicating copy to clipboard operation
tinyxml2 copied to clipboard

Unable to encode not printable char

Open francescop86 opened this issue 6 years ago • 1 comments

I am unable to encode not printable ASCII.

Using Visual Studio 2015 I am running following code

XMLDocument doc;
XMLDeclaration* decl = doc.NewDeclaration("xml version = \"1.0\" encoding = \"UTF-8\" ");
doc.LinkEndChild(decl);

pValue = doc.NewElement("Value");
pValue->SetText(" I am not printable ASCII: \x02 \x7f");

Expected result: <Value>I am not printable ASCII: &#x02 &#x7f </Value>

Observed result Non printable ASCCI are not encoded into std xml

NOTE: The decoding work fine, if into xml file this string is founded &#0d it is correctly converted into [CR] ASCII

francescop86 avatar Feb 21 '19 17:02 francescop86

I have tried also to set version 1.1 but it still does not encode.

XMLDeclaration* decl = doc.NewDeclaration("xml version = \"1.1\" encoding = \"UTF-8\" ");

francescop86 avatar Feb 22 '19 09:02 francescop86