Results 1 to 3 of 3

Thread: ASCII vs UNICODE

  1. #1

    Thread Starter
    Hyperactive Member chuddy's Avatar
    Join Date
    Oct 2002
    Posts
    333

    ASCII vs UNICODE

    How do I ensure that the characters that I am using are in either UNICODE or ASCII?

    e.g.

    is

    Code:
    const char* aString = "hello";
    going to be stored in ASCII or UNICODE?

    Thanks!

  2. #2
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771

    Re: ASCII vs UNICODE

    "hello" is always an ASCII string, L"hello" is always a Unicode string. If you want a program that works in both Unicode and ASCII builds you should use something like:
    Code:
    #ifdef UNICODE
    #define _T(X) L ## X
    #else
    #define _T(X) X
    #endif
    
    _T("my string") // becomes L"my string" in unicode builds

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: ASCII vs UNICODE

    Actually, "hello" is always in the implementation's native character set (Windows-1252 for VC++, ISO-8859-1 (known as Latin-1) for GCC on x86, but for example EBCDIC for some old IBM-based imlementations, which is not a superset of ASCII), while L"hello" is always in the implementation's wide character set (UTF-16 for both GCC and VC++, I think, though it might be UCS-2 or even UCS-4 for some compilers).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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