I am modernizing a large, legacy MFC codebase which contains a veritable medley of string types:
- CString
- std::string
- std::wstring
- char*
- wchar_t*
- _bstr_t
I'd like to standardize on a single string type internally, and convert to other types only when absolutely required by a third-party API (i.e. COM or MFC functions). The question my coworkers and I are debating; which string type should we standardize on?
I would prefer one of the C++ standard strings: std::string or std::wstring. I'm personally leaning toward std::string, because we do not have any need for wide characters - it is an internal codebase with no customer-facing UI (i.e. no need for multiple-language support). "Plain" strings allow us to use simple, unadorned string literals ("Hello world" vs L"Hello world" or _T("Hello world")).
Is there an official stance from the programming community? When faced with multiple string types, what is typically used as the standard 'internal' storage format?
If we talk about Windows, than I'd use std::wstring (because we often need cool string features), or wchar_t* if you just pass strings around.
Note Microsoft recommends that here: Working with Strings
Also:
Also: