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

查看:28
本文介绍了如何使用 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.你可以使用这个标准标准

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天全站免登陆