【发布时间】:2016-01-04 15:02:42
【问题描述】:
有没有一种简单的方法(一行代码会很酷)在 C++/CX 中将 à std::string 转换为 Platform::String^ ?
我找到了how to do it the other way(String^ to string) 但没有找到这个。
类似:
std::string str = "Hello World";
Platform::String^ p_str = convertFromString(str);
(在示例中它毫无意义,但是当您在 c++ 中使用 std::string 并且您想将其发送到某些 C# 代码时更有意义)
【问题讨论】:
-
您总是可以尝试使用 charArray 在它们之间进行转换?
-
叹息,22 年的 Unicode 并没有阻止这样的问题。您已经知道如何从该帖子转换为 std::wstring 。然后是单线,ref new String(wide.c_str())
-
我可以制作其他东西(使用 char * 等...),但我想知道是否有一种好的/简单的方法
标签: c# c++ c++-cx windows-rt