如何将CString转换为字节 [英] how to convert CString to Bytes
本文介绍了如何将CString转换为字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我实际上是试图将csharp代码转换为c ...下面是C#代码。
CString数据=世界是美丽的;
Byte [] quote = ASCIIEncoding.UTF8.GetBytes(data);
在上面的代码中...它将字符串转换为字节。类似地,我可以使用C进行转换。
谁能告诉我C中的等效代码是什么?
请帮助我
解决方案
CString是C ++类,因此在C中实现它的可能性很小。 / p>
但是,如果您希望将其作为标准的多字节编码字符串来获取,则可以执行以下操作
CString data =世界很美;
CStringA mbStr =数据;
char *字节= mbStr.GetString();
i am actually tryin to convert a csharp code to c... below is the C# code..
CString data = "world is beautiful";
Byte[] quote = ASCIIEncoding.UTF8.GetBytes(data);
in the above code... it converts the string into bytes..similarily is ther a way that i can convert it using C.. Can any body tell what wud be the quivalent code in C? Please help me guys
解决方案
Well CString is a C++ class so doing it in C is a little unlikely.
But if you wish to get it as a standard multi-byte encoded string then you can do the following
CString data = "world is beautiful";
CStringA mbStr = data;
char* bytes = mbStr.GetString();
这篇关于如何将CString转换为字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文