如何使用RapidXML读取Unicode XML值 [英] How to read Unicode XML values with rapidxml

查看:166
本文介绍了如何使用RapidXML读取Unicode XML值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RapidXML是可用于在c ++中解析XML的库之一.为了获得值,我们可以使用类似以下内容的方法:

RapidXML is one of the available libraries for parsing XML in c++. For getting the values, we can use something like:

node->first_node("xmlnode")->value()

此命令返回char *数据类型.有什么方法可以将值读取为Unicode,以便可以在WCHAR或wstring变量中进行分配?

This command returns a char* data type. Is there any way to read the value as Unicode so I can assign it in a WCHAR or wstring variable?

推荐答案

在这里,您需要将str转换为wstr. 您可以使用此标准STD

here you need convert str to wstr. you can use for this standart std

#include <string>
#include <codecvt>
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;

std::string strSample; // convert str to wstr
std::wstring wstrValue = converter.from_bytes(strSample);

std::wstring wstrSample; // convert wstr to str
std::string strValue = converter.to_bytes(wstrSample);

希望获得帮助

这篇关于如何使用RapidXML读取Unicode XML值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆