windows - How to deal with Unicode strings in C/C++ in a cross-platform friendly way? -
on platforms different windows use char *
strings , treat them utf-8.
the problem on windows required accept , send messages using wchar* strings (w). if you'll use ansi functions (a) not support unicode.
so if want write portable application need compile unicode on windows.
now, in order keep code clean see recommended way of dealing strings, way minimize ugliness in code.
type of strings may need: std::string
, std::wstring
, std::tstring
,char *
,wchat_t *
, tchar*
, cstring
(atl one).
issues may encounter:
cout/cerr/cin
, unicode variantswcout,wcerr,wcin
- all renamed wide string functions , tchar macros -
strcmp
,wcscmp
,_tcscmp
. - constant strings inside code, tchar have fill code
_t()
macros.
what approach see being best? (examples welcome)
personally go std::tstring
approach see how conversions necessary.
i can suggest check library out: http://cppcms.sourceforge.net/boost_locale/docs/
might help, it's boost candidate believe make it.
Comments
Post a Comment