Thread: Unicode 2 byte wide characters

  1. #16
    Registered User
    Join Date
    Jan 2009
    Posts
    61
    i did read the man page... from my re-reading i changed %C to %c but otherwise i dont know what to do -- arg1 is a pointer to a wide char array? arg2 is the maximum length of the string (?) arg 3 is the format and the rest are referred to in the format...

    is this correct?

    ps, dont get my wrong i love how you dont tell me, but rather let me learn on my own (i just need a small extra clue )

  2. #17
    Registered User
    Join Date
    Jan 2009
    Posts
    61
    ok im going for the sprintf the bytes to a char array and going from there i found this piece of code does not compile

    Code:
    #include <stdio.h>
    #include <wchar.h>
    
    int main() {
    
    
            char ch[] = {0x00, 0x6C, 0x00, 0x6F, 0x00, 0x00};
            printf("%S", (wchar_t*)ch);
    
    return 0;
    
    }
    at all i tried it on multiple architectures.. nothing. right now if i could print the array file_name then i would be a happy person. another thing, does creat() take UTF-16?

    thanks

  3. #18
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    The following works for me in VS2005
    Code:
    #include <stdio.h>
    #include <wchar.h>
    
    int main() 
    {
        char ch[] = {0x6C, 0x00, 0x6F, 0x00, 0x00,0x00 };
        wchar_t* pCh = (wchar_t*)ch;
        wprintf(L"%s\n", pCh);
        printf("%S\n", pCh);
        return 0;
    }
    I have no gcc to check it as well
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #19
    Registered User
    Join Date
    Jan 2009
    Posts
    61
    that interprets it as a 1 byte string, becuase it prints 'l' (ell) and quits, also if you add a trailing 0x00, (which is evident in my string) then it doesnt print anything...

    this is becming an annoyance... is it really that hard to print a 16 bit character string?

    (Im not paying out on you, im just surprised :s)

    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. C++ jargons: Really CONFUSING
    By cavestine in forum C++ Programming
    Replies: 3
    Last Post: 10-15-2007, 04:19 PM
  3. pass multi-byte (or wide) characters to DeleteFile
    By George2 in forum C Programming
    Replies: 1
    Last Post: 07-30-2007, 12:56 AM
  4. Unicode - a lot of confusion...
    By Jumper in forum Windows Programming
    Replies: 11
    Last Post: 07-05-2004, 07:59 AM
  5. Reading Unicode characters
    By Troll_King in forum Windows Programming
    Replies: 0
    Last Post: 10-18-2001, 12:57 AM