Boost logo

Boost Users :

Subject: [Boost-users] Encoding with read_xml()
From: ashish g (coooolashish4u_at_[hidden])
Date: 2015-08-20 09:48:56


I was looking into using the function 'read_xml()' which parses an xml file
and populates a ptree. However I had a couple of questions which I couldnt
find documentation for.

1. Is the encoding of the xml file format preserverd when the data is
stored into the ptree. i.e lets say I have an xml file in utf-8 format. Are
the strings inside my ptree utf-8 encoded as well? Or is it converted to
system default encoding?

2. Passing the locale information as an argument to read_xml(), what effect
does it have? I believe it assumes the xml file is formatted using the
locale encoding, or uses system locale encoding if no arg is passed. Is
this true even if my xml 's first line explicitly states that it uses and
encoding diff from the system encoding.

for eg: lets say im on windows with 1252 encoding. My xml file is utf-8,
and is specified on the first line. If i call read_xml() on this file,
without passing a locale as arg, does it use system 1252 encoding to parse
the file or utf-8?

Any pointers would be very helpful.

Thank you

*Ashish Gudla*

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at