[Interest] Question about QTextStream and codecs

Thiago Macieira thiago.macieira at intel.com
Fri May 26 17:37:18 CEST 2017


On Friday, 26 May 2017 05:22:25 PDT Murphy, Sean wrote:
> I am on Windows, sorry I forgot to mention that in the original post
> 
> > b) your input XML file has a UTF-8 BOM.
> 
> I don't think the input file has any BOM, unless my hex editor is playing
> tricks on me. Opening the input file in the hex editor the first byte shown
> is an 0x3c, which is the opening '<' of the first xml tag.

Oh well, then your code is broken anyway. Clearly your input is UTF-8 (the XML 
says so), but you're reading it using your locale's codec.

You should set the codec to UTF-8 in both the input and output QTextStream.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list