std::map of char* keys

This is a discussion on std::map of char* keys within the C++ Programming forums, part of the General Programming Boards category; At least it allows you to work internationally natively without extra libraries. If you are going to deal with real ...

  1. #16
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,230
    At least it allows you to work internationally natively without extra libraries.
    If you are going to deal with real international issues you are going to need more than `std::wstring'.

    At the very least, the standard interface is insufficient for iterating over storage boundaries, code points, and character boundaries. Literally, you simply can't do those three things with the standard interface unless they happen to be the same thing.

    Then there are issues with locales. The standard doesn't even require anything other than the "C Locale". Even if it did, the locale mechanism of C++ is insufficient for expressing some artifacts of several languages.

    As a consequence of this last part, consuming input in anything complex, like some currency, using only the standard C++ libraries becomes impossible even if you could enumerate and activate the relevant locale because the internal parsing is broken by definition.




    Since std::string works with char, it means you cannot iterate a utf-8 string since it will always move one byte at a time.
    This is also true for `std::wstring', and `std::wstring' adds some confusion of its own.

    Under Windows, `std::wstring' will likely be built from 16 bit units representing an incomplete UTF16 code set.

    Under GNU/Linux, `std::wstring' will likely be built from 32 bit units representing an incomplete UTF32 code set.

    Under other systems `std::wstring' may be built from 8 bit units representing something that isn't even a part of the Unicode standard.

    In other words, you may not be able to count on `std::wstring' iterating on any given boundary, and even if you could you can't count on it iterating over a given code point correctly.




    I do believe that wstrings are a better alternative.
    To get reasonably portable source (It is not acceptable for the programmer to do all the work of multiple library implementations.) you would have to use a third-party implementation of `std::wstring' in the first place.

    Seriously, take the time to compare the usability of `std::string', `std::wstring', and the locales mechanism under MSVC, GCC on GNU/Linux, GCC (MinGW), and any fourth compiler of your choice.

    The situation for internationalization within the standard C++ libraries is abysmal. You are far better off using a library that knows more about Unicode, quirky locales, and has a decent repertoire of locales available across all targeted systems.




    Oh, and god help you if you are doing anything fancy with the text. If you are going to try and highlight misspelled words... actually don't. You are better off shipping a dictionary with your software than to try and get a combination like Hungarian quoting English quoting French with a misspelled word highlighting correctly.

    Soma

  2. #17
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    I am pretty aware that there are big problems with internalization and unicode in the language, and std::string and std::wstring. Nevertheless, of the possible alternatives, wstrings work better with internationalizing to my experience.
    If I were given a choice of using a broken tool and a yet more broken tool, I would use the broken tool. It's better than nothing.
    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.

  3. #18
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,230
    O_o

    Yea, if you are going to choose between having to deal with 4 tons of crap or only 7999 pounds you may as well save yourself that last shovel.

    Soma

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 12-19-2010, 12:56 PM
  2. Simulate Keys with a Keyboard Hook
    By guitarist809 in forum Windows Programming
    Replies: 3
    Last Post: 11-14-2008, 07:14 PM
  3. blocking or passing keys with global hook
    By pmouse in forum Windows Programming
    Replies: 4
    Last Post: 08-29-2007, 02:54 PM
  4. Interfacing with arrow keys...
    By adityakarnad in forum Game Programming
    Replies: 1
    Last Post: 08-30-2003, 10:25 PM
  5. Arrow Keys and Such
    By Thantos in forum Game Programming
    Replies: 5
    Last Post: 10-25-2001, 05:40 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21