printing wide characters to strings...

This is a discussion on printing wide characters to strings... within the C Programming forums, part of the General Programming Boards category; hello everyone, i have a for looop that iterates through an array of bytes, each two byte sequence is a ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    61

    printing wide characters to strings...

    hello everyone,

    i have a for looop that iterates through an array of bytes, each two byte sequence is a 2 byte wide character, i need to print each two byte sequence to a wchar_t array. I have written some code but i need a few pointers on where to go from here:

    Code:
    	for(i = 0 ; i < name_len ; i++){
    		swprintf(&file_name[i], 1, L"%C",((((u8_t *)p->payload)[i+6] << 8) | ((u8_t *)p->payload)[i+6+1]));
    		printf("%C",file_name[i]);
    	        }
    but that yields a 00000000... etc array

    thanks for your help!

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    shouldn't you cast to uint16 before <<8 ?

    also - I'm not sure that using %C in swprintf is a right thing to print wide char
    Have you checked the docs?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings using special characters [ ]
    By mtronix in forum C++ Programming
    Replies: 9
    Last Post: 09-25-2007, 03:29 PM
  2. Printing different representations of characters...
    By smoothdogg00 in forum C Programming
    Replies: 3
    Last Post: 03-04-2006, 12:05 PM
  3. strings or arrays of characters?
    By Callith in forum C++ Programming
    Replies: 13
    Last Post: 12-26-2004, 10:28 AM
  4. printing char* strings
    By difficult.name in forum C Programming
    Replies: 4
    Last Post: 12-10-2004, 06:06 PM
  5. Getting weird characters in Strings
    By steve8820 in forum C Programming
    Replies: 3
    Last Post: 09-18-2001, 02:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21