如何将wchar_t *转换为std :: string? [英] How do I convert wchar_t* to std::string?

查看:431
本文介绍了如何将wchar_t *转换为std :: string?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将班级更改为使用std :: string(基于我得到的答案此处,但是我拥有的函数返回wchar_t *。如何将其转换为std :: string?

I changed my class to use std::string (based on the answer I got here but a function I have returns wchar_t *. How do I convert it to std::string?

我尝试过:

std::string test = args.OptionArg();

,但显示错误C2440:正在初始化:无法从 wchar_t *转换为 std :: basic_string< _Elem,_Traits ,_Ax>'

but it says error C2440: 'initializing' : cannot convert from 'wchar_t *' to 'std::basic_string<_Elem,_Traits,_Ax>'

推荐答案

您可以只使用 wstring 并保留所有内容Unicode

You could just use wstring and keep everything in Unicode

这篇关于如何将wchar_t *转换为std :: string?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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