#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    138
    Rep Power
    12

    Question Conversion of Unicode to ASCII


    Hi,
    I am trying to convert CString into char,but when i use the following code

    char *cptr;
    CString mCCContent;

    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
    Raghuraman
    Last edited by Raghuraman; July 17th, 2003 at 11:15 AM.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    USA
    Posts
    286
    Rep Power
    14
    Try using either WideCharToMultiByte or wcstombs.
    Jon Sagara

    "Me fail English? That's unpossible!"
  4. #3
  5. No Profile Picture
    .
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Posts
    296
    Rep Power
    13
    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.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    138
    Rep Power
    12
    Hi Jon,
    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.

IMN logo majestic logo threadwatch logo seochat tools logo