简体   繁体   English

如何将字符串从C#传递到C ++指定编码

[英]How to pass string from C# to C++ specifying encoding

I'm writing native C++ library to be used from C#. 我正在编写要从C#使用的本机C ++库。 I need a C++ method receiving string (or char array) and Encoding. 我需要一个C ++方法来接收字符串(或char数组)并进行编码。 Inside this method I want to convert this string to byte array with respect of Encoding, work with it and send back string converted from byte array with respect of Encoding. 在此方法内部,我想将此字符串转换为与Encoding有关的字节数组,对其进行处理,然后将从字节数组转换为Encoding的字符串发送回。 As far as this method will be called from C#, I can pass System.Text.Encoding to it, but I don't know any analog in C++ for it. 就可以从C#调用此方法而言,我可以将System.Text.Encoding传递给它,但是我不知道C ++中有任何类似的形式。 What approach would you suggest? 您会建议哪种方法?

如果只想对字节进行操作,则将字节数组传递给C ++库会容易得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM