[Qt-interest] QXmlStreamWriter not adding encoding attribute.
Andreas Pakulat
apaku at gmx.de
Tue May 17 09:00:30 CEST 2011
On 16.05.11 23:44:13, JD Guzman wrote:
> Hello all,
>
> Now I may be doing something wrong but I can't seem to get the xml stream writer to add the encoding attribute to the xml tag. Here is my sample code.
>
> QString meta;
> QXmlStreamWriter writer(&meta);
> writer.setAutoFormatting(true);
> writer.writeStartDocument();
> writer.writeEndDocument();
>
> return meta;
>
>
> Here is what the output looks like.
>
> <?xml version="1.0"?>
>
> As you can see this is not what I woud expect which is.
Why not? If you look into the XML standard you'll notice that no
encoding attribute means the encoding of the file has to be utf-8. So
adding an explicit encoding attribute that states this would be
redundant.
If you change the encoding to something other than utf-8 the writer
should add the encoding attribute.
Andreas
More information about the Qt-interest-old
mailing list