Thread: Special Characters

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Unicode and MBCS (multi-byte charset) should not be interchanged, if possible. Either you use unicode in your app or MCBS.
    It's quite possible the √ exists in MBCS too.
    For Windows programming, I suggest the use of Unicode.
    There are functions that can convert to and from Unicode, but unless you really need them, it's not really recommended.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You can convert to and from, wide and narrow strings using mbstowcs() and wcstombs(). Here's one way to append an narrow string to a wide string:
    Code:
    void AppendAtoW(std::wstring &wstr, const char *astr)
    {
        const size_t buff_len = 128;
        wchar_t buff[buff_len];
        mbstowcs(buff, astr, buff_len);
        buff[buff_len - 1] = 0; // in case astr is longer than buff_len
        wstr += buff;
    }//AppendAtoW
    >> my_str = L"√";
    This seems dangerous to me - because of two assumptions: 1) that your code editor saves your source code the "right" way; 2) that your compiler interprets the string literal as you expect. For (2), I'm not real familiar with what the standard has to say about this - but I'll start reading.

    However, it sure is nice to see the same glyph in your source code that you intend to show in the control And it seems that mikeman118's editor and compiler are doing the "right" thing - based on the output: "√琠獥t쳌쳌쳌쳌".

    gg

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Are you doing pure Win32 programming for Windows? It looks that way to me.
    I'd rather recommend you get a framework like MFC.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183
    Thank you everyone, everything works now!

    BTW Codeplug I'm using Visual C++ 2008 Express Edition, in case you were wondering.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. Bubblesort with special characters
    By Zarniwoop in forum C Programming
    Replies: 3
    Last Post: 05-03-2008, 10:43 PM
  3. special characters removing from srting
    By cnu_sree in forum C Programming
    Replies: 5
    Last Post: 06-06-2007, 08:30 PM
  4. special characters
    By volk in forum C Programming
    Replies: 8
    Last Post: 02-20-2003, 03:57 AM
  5. Special (non) Keyboard Characters
    By TechWins in forum C++ Programming
    Replies: 3
    Last Post: 05-01-2002, 12:08 AM