how to convert CString to Bytes
Question
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
Solution
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();
OTHER TIPS
In C the char type is defined as one byte in memory. Hence storing your string as a char * would be equivalent to storing a byte array in C#.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow