RE: wide chars and methods

From: Vidya Maheshwar Nabar (vidyan@aztec.soft.net)
Date: Fri Oct 28 2005 - 03:11:52 CST

  • Next message: Andrew S: "Roman Numerals (was Re: Improper grounds for rejection of proposal N2677)"

     
    Hi Shawn/Dominikus,
     
    Thanks for the response.
     
    I don't want to use TCHAR around the code for some reason. I thought I
    should be using 'wchar_t' for holding Japanese text, but 'char ' seemed to
    work fine. As for wchar_t, I could see Japanese strings only after I made a
    setlocale( LC_ALL, "" ) call, (though I still cannot 'type in' Japanese;
    when the focus is in the console, the Japanese IME which is otherwise
    displayed, disappears), hence the question about wide char/method usability.
    - Why do we need setlocale when using wchar_t to display Japanese strings?
    Even with this workaround, I'm still unable to enter Japanese strings via
    console.
    - This distinction doesn't seem to extend to file streams. So, does console
    i/o differ from disk i/o? I tried reading from/writing to files with
    Japanese strings using both char and wchar_t (sans setlocale) without any
    issues.
     
    Regards,
    Vidya.
     
     
     
    -----Original Message-----
    From: Shawn Steele [mailto:Shawn.Steele@microsoft.com]
    Sent: Tuesday, October 25, 2005 11:37 PM
    To: Vidya Maheshwar Nabar; unicode@unicode.org
    Subject: RE: wide chars and methods
     
    Windows 2000 Server is natively Unicode. You cannot "hold all the
    characters" of that OS in an 8 bit char.
     
    The windows console is restricted to "ansi" code pages, which is probably
    why you're seeing the behavior you're seeing. Its strongly recommended that
    you avoid using ANSI applications and use Unicode instead.
     
    - Shawn
     
    SDE, Microsoft
     
      _____

    From: unicode-bounce@unicode.org [mailto:unicode-bounce@unicode.org] On
    Behalf Of Vidya Maheshwar Nabar
    Sent: Tuesday, October 25, 2005 2:55 AM
    To: unicode@unicode.org
    Subject: wide chars and methods
     
     
    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 : Fri Oct 28 2005 - 08:38:43 CST