C++ cli 托管c++;至clr,针脚至针脚或内部针脚

C++ cli 托管c++;至clr,针脚至针脚或内部针脚,c++-cli,clr,managed-c++,C++ Cli,Clr,Managed C++,我正在尝试编译一个项目,该项目以前使用/oldsyntax,但现在使用/clr std::string Jhc::Interop::stlString(System::String^ s) { std::string out; const wchar_t __pin * str = PtrToStringChars(s); int len = s->Length*4; char *buf = new char[len]; memset(buf,len

我正在尝试编译一个项目,该项目以前使用/oldsyntax,但现在使用/clr

std::string Jhc::Interop::stlString(System::String^ s)
{
    std::string out;
    const wchar_t __pin * str = PtrToStringChars(s);
    int len = s->Length*4;
    char *buf = new char[len];
    memset(buf,len,0);
我已将
System::String*s
更改为
System::String^s
,但如何使用
PtrToStringChars转换该行


我尝试过使用
pin_ptr
interior_ptr
,但无法正常工作。

能否显示编译错误?也许您想将其改为
std::wstring
?如果没有,那么您需要执行从宽字符到UTF8的区域设置转换;我在msdn上找到了它: