|
Boost Users : |
Subject: [Boost-users] [serialization]Nans and infinity in wide xml archive
From: Elizabeta (elizabeta.petreska_at_[hidden])
Date: 2017-07-03 09:23:19
Hi
I am using wide xml boost serialization archive. Because of the problem with
loading of nans and infinities I tried the nonfinite facet as in the code
snippet. This works, expect
it messes with the encoding of the xml arhive which is no longer UTF-8 like
before the using the facet, and I believe it is because of the no_codecvt
flag which is passed to the archive. But without this flag the loading of
nans/infinity does not work. How to use the facet and keep the wanted UTF-8
encoding ?
float d = std::numeric_limits<float>::quiet_NaN;
{
std::wofstream oss("C:\\test.xml");
std::locale locale1(oss.getloc(), new
boost::math::nonfinite_num_put<wchar_t>);
oss.imbue(locale1);
xml_woarchive oar(oss, no_codecvt);
oar << BOOST_SERIALIZATION_NVP(d);
}
{
float d;
std::wifstream iss("C:\\test.xml");
std::locale locale1(iss.getloc(), new
boost::math::nonfinite_num_get<wchar_t>);
iss.imbue(locale1);
xml_wiarchive iar(iss, no_codecvt);
iar >> BOOST_SERIALIZATION_NVP(d);
std::cout << d << std::endl;
}
-- View this message in context: http://boost.2283326.n4.nabble.com/serialization-Nans-and-infinity-in-wide-xml-archive-tp4696397.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net