According to the manual, pugi::char_t
is either char
or wchar_t
, depending on your library configuration. This is so that you can switch between single bytes (ASCII or UTF-8) and double bytes (usually UTF-16/32).
This means you don't need to change it to anything. However, if you're using the wchar_t*
variant, you will have to use the matching stream object:
#ifdef PUGIXML_WCHAR_MODE
std::wcout << it->name();
#else
std::cout << it->name();
#endif
And, since you asked, to construct a std::string
or std::wstring
from it:
#ifdef PUGIXML_WCHAR_MODE
std::wstring str = it->name();
#else
std::string str = it->name();
#endif
Or, for always a std::string
(this is rarely what you want!):
#ifdef PUGIXML_WCHAR_MODE
std::string str = as_utf8(it->name());
#else
std::string str = it->name();
#endif
Hope this helps.
Source: A cursory glance at the "pugixml" documentation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…