Subject: [Boost-bugs] [Boost C++ Libraries] #8836: boost::property_tree and BOM
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-07-17 11:47:58
#8836: boost::property_tree and BOM
--------------------------------+---------------------------
Reporter: nikita.trophimov@⦠| Owner: cornedbee
Type: Bugs | Status: new
Milestone: To Be Determined | Component: property_tree
Version: Boost 1.54.0 | Severity: Problem
Keywords: property_tree |
--------------------------------+---------------------------
boost::property_tree::ptree can't handle files with BOM (at least for
UTF-8).
{{{
#include <boost/filesystem.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <cstdlib>
#include <iostream>
int main()
{
try
{
boost::filesystem::path path("helper.ini");
boost::property_tree::ptree pt;
boost::property_tree::read_ini(path.string(), pt);
const std::string foo = pt.get<std::string>("foo");
std::cout << foo << '\n';
}
catch (const boost::property_tree::ini_parser_error& e)
{
std::cerr << "An error occurred while reading config file: " <<
e.what() << '\n';
return EXIT_FAILURE;
}
catch (const boost::property_tree::ptree_bad_data& e)
{
std::cerr << "An error occurred while getting options from config
file: " << e.what() << '\n';
return EXIT_FAILURE;
}
catch (const boost::property_tree::ptree_bad_path& e)
{
std::cerr << "An error occurred while getting options from config
file: " << e.what() << '\n';
return EXIT_FAILURE;
}
catch (...)
{
std::cerr << "Unknown error \n";
return EXIT_FAILURE;
}
}
}}}
'''helper.ini'''
foo=str
'''Output'''
An error occurred while getting options from config file: No such node
(foo)
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8836> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC