Results 1 to 3 of 3

Thread: [RESOLVED] How to read a UNICODE string into char buffer

  1. #1

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Resolved [RESOLVED] How to read a UNICODE string into char buffer

    Hi all,

    I want to read a UNICODE string into a char buffer. So I do the following.

    Code:
    	std::string temp = GetAsString();
    	std::cout << temp << std::endl;
    
    	char buff[256] = {0};
    	int val = sprintf(buff, "%s", temp.c_str());
    GetAsString() method return a UNICODE string. That's mean there is a zero/null after each character, so in sprintf() it terminate after finding the null. So only first character is added to the buffer. How can I fix it.

    Thanks
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  2. #2
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: How to read a UNICODE string into char buffer

    http://www.google.com/search?hl=en&q...te&btnG=Search

    You are going to need to convert it from unicode to ascii because I don't think console supports unicode. (It might, Not sure)

  3. #3

    Thread Starter
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: How to read a UNICODE string into char buffer

    Thanks for the replay. I solve the problem
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width