unicode编码. 要求能写入 <urls>
<url>www.11.com</url>
<url>www.12.com</url>
<url>www.13.com</url>
</urls> try
{
std::locale l_OldLocale;
std::locale l_UTF8Locale(l_OldLocale,new boost::filesystem::detail::utf8_codecvt_facet()); boost::property_tree::read_xml(pFile,datum_c,0,l_UTF8Locale);
BOOST_FOREACH(const std::wstring & name, _value)
datum_c.put(pKey, name,/*true如果ascii 编码,使用这个参数可以实现目标,但unicode */);
write_xml(m_pFile, datum_c);
return true;
}
catch (std::exception &e)
{
m_errmsg=e.what();
}
return false;
但unicode 出现如何编译错误:1>f:\cpplib\boost_1_47\boost\property_tree\detail\ptree_implementation.hpp(795): error C2228: left of '.put_value' must have class/struct/union
1> type is 'bool'
1> f:\cpplib\boost_1_47\boost\property_tree\detail\ptree_implementation.hpp(817) : see reference to function template instantiation 'void boost::property_tree::basic_ptree<Key,Data>::put_value<Type,Translator>(const Type &,Translator)' being compiled
1> with
1> [
1> Key=std::wstring,
1> Data=std::wstring,
1> Type=std::wstring,
1> Translator=bool
1> ]
1> e:\other\xfsj2\configxml\readxml.cpp(48) : see reference to function template instantiation 'boost::property_tree::basic_ptree<Key,Data> &boost::property_tree::basic_ptree<Key,Data>::put<std::wstring,bool>(const boost::property_tree::string_path<String,Translator> &,const Type &,bool)' being compiled
1> with
1> [
1> Key=std::wstring,
1> Data=std::wstring,
1> String=std::wstring,
1> Translator=boost::property_tree::id_translator<std::wstring>,
1> Type=std::wstring
1> ]
1>
1>Build FAILED.
<url>www.11.com</url>
<url>www.12.com</url>
<url>www.13.com</url>
</urls> try
{
std::locale l_OldLocale;
std::locale l_UTF8Locale(l_OldLocale,new boost::filesystem::detail::utf8_codecvt_facet()); boost::property_tree::read_xml(pFile,datum_c,0,l_UTF8Locale);
BOOST_FOREACH(const std::wstring & name, _value)
datum_c.put(pKey, name,/*true如果ascii 编码,使用这个参数可以实现目标,但unicode */);
write_xml(m_pFile, datum_c);
return true;
}
catch (std::exception &e)
{
m_errmsg=e.what();
}
return false;
但unicode 出现如何编译错误:1>f:\cpplib\boost_1_47\boost\property_tree\detail\ptree_implementation.hpp(795): error C2228: left of '.put_value' must have class/struct/union
1> type is 'bool'
1> f:\cpplib\boost_1_47\boost\property_tree\detail\ptree_implementation.hpp(817) : see reference to function template instantiation 'void boost::property_tree::basic_ptree<Key,Data>::put_value<Type,Translator>(const Type &,Translator)' being compiled
1> with
1> [
1> Key=std::wstring,
1> Data=std::wstring,
1> Type=std::wstring,
1> Translator=bool
1> ]
1> e:\other\xfsj2\configxml\readxml.cpp(48) : see reference to function template instantiation 'boost::property_tree::basic_ptree<Key,Data> &boost::property_tree::basic_ptree<Key,Data>::put<std::wstring,bool>(const boost::property_tree::string_path<String,Translator> &,const Type &,bool)' being compiled
1> with
1> [
1> Key=std::wstring,
1> Data=std::wstring,
1> String=std::wstring,
1> Translator=boost::property_tree::id_translator<std::wstring>,
1> Type=std::wstring
1> ]
1>
1>Build FAILED.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货