Switching from std::string to std::wstring for embedded applications?

后端 未结 3 499
情书的邮戳
情书的邮戳 2021-01-03 07:11

Up until now I have been using std::string in my C++ applications for embedded system (routers, switches, telco gear, etc.).

For the next project, I am considering t

3条回答
  •  -上瘾入骨i
    2021-01-03 07:55

    Note that many communications protocols require 8-bit characters (or 7-bit characters, or other varieties), so you will often need to translate between your internal wchar_t/wstring data and external encodings.

    UTF-8 encoding is useful when you need to have an 8-bit representation of Unicode characters. (See How Do You Write Code That Is Safe for UTF-8? for some more info.) But note that you may need to support other encodings.

    More and more third-party libraries are supporting Unicode, but there are still plenty that don't.

    I can't really tell you whether it is worth the headaches. It depends on what your requirements are. If you are starting from scratch, then it will be easier to start with std::wstring than converting from std::string to std::wstring later.

提交回复
热议问题