July 17th, 2003, 08:34 AM
Conversion of Unicode to ASCII
I am trying to convert CString into char,but when i use the following code
int length = mCCContent.GetLength();
cptr = mCCContent.GetBuffer(length);
I get an error saying cannot convert from unsigned short* to char*.
The reason i am doing this is to collect the entire CString and convert each character into interger so i could do encryption of that by adding another ascii value.
Any immediate help will be highly appreciated.
Thank you all in advance
The purpose of my conversion is for encryption. I have to take each ASCII value of the CString buffer and change the ascii value.. For example if I have HELLO, I need to change H to another ascii value say %. So, I would like to know how to convert this unicode to ascii.
Any help from anyone is most welcome
Thank you in advance
Last edited by Raghuraman; July 17th, 2003 at 11:15 AM.
July 17th, 2003, 12:05 PM
Try using either WideCharToMultiByte or wcstombs.
"Me fail English? That's unpossible!"
July 17th, 2003, 02:09 PM
there's, i don't know, something like 70,000 possible characters in the unicode char set, and there's only 128 possible in ascii.
cstring is not unicode. cstring is ascii - same thing, at least it is on my system i think.
July 18th, 2003, 04:37 PM
Thank you very much for your suggestion and when i used wcstombs I was indeed able to convert the unicode into ascii.
PS Balance..Thank you for your prompt reply but in general atleast in my machine the CString is stored as UNICODE and hence the need arised for converting it into ascii char.