wide chars and methods

From: Vidya Maheshwar Nabar (vidyan@aztec.soft.net)
Date: Tue Oct 25 2005 - 03:54:32 CST

  • Next message: Andrew S: "Re: Poll about accessing Unicode is about to end"

     
    Hi,
     
    I wanted to know why 'wchar_t' data type is required if a 'char' can very
    well hold all the characters on a given OS. To elaborate, I run the program
    below on a Japanese Win 2K Server and pass Japanese strings:
     
    Code Snippet(VC++ 6.0):
    char str[MAX];
    cin >> str;
    cout << str << endl;
     
    Input:
    'Ü'¹'ñ
     
    Output:
    'Ü'¹'ñ
     
    Note: here, input is U+307E,U+305B and U+3093.
     
    The above program runs fine with chars and cin/cout/scanf/printf, in fact
    things go weird when I use wchars and wcin/wcout/wscanf/wprintf, it just
    doesn't output anything!
     
    How/Why is cin/cout/scanf/printf able to process Japanese strings on a
    Japanese machine with a char, and not wcin/wcout/wscanf/wprintf with wchar?
    Isn't that wchars/wide methods are needed for chars beyond the 8-bit range
    as char can't handle it? Am I missing something here?
     
    Thanks in advance.
     
    Regards,
    Vidya.
     



    This archive was generated by hypermail 2.1.5 : Tue Oct 25 2005 - 03:54:02 CST