Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我实际上正在尝试将 csharp 代码转换为 c ... 下面是 C# 代码..
CString data = "world is beautiful"; Byte[] quote = ASCIIEncoding.UTF8.GetBytes(data);
在上面的代码中......它将字符串转换为字节......类似地,我可以使用 C 转换它。任何人都可以告诉 wud 是 C 中的等效代码吗?请帮帮我
好吧,CString 是一个 C++ 类,所以在 C 中做它有点不太可能。
但是,如果您希望将其作为标准的多字节编码字符串,则可以执行以下操作
CString data = "world is beautiful"; CStringA mbStr = data; char* bytes = mbStr.GetString();
在 C 中,char 类型被定义为内存中的一个字节。因此,将字符串存储为 char * 相当于在 C# 中存储字节数组。