Not. The fundamental problem with trying to use typedef to βfixβ the type of character is that you get what is compatible with built-in functions and wide characters on some platforms, but not on other platforms.
If you need a string format that will be the same on all platforms, you can simply choose the size and signature. Do you need unsigned 8-bit "characters" or signed 64-bit "characters"? You can have them on any platform that has an integer type of the appropriate size (not all). But they are not characters in terms of language, so do not expect that you can call them strlen or wcslen or have good syntax for literals. A string literal (well, converted) is a char* , not a signed char* or unsigned char* . A wide string literal is wchar_t* , which is equivalent to some other integer type, but not necessarily the one you want.
So, you need to select the encoding, use it internally, determine your own versions of the string functions that you need, implement them, and then convert to / from the platform encoding, if necessary, for non-string functions that accept strings. utf-8 is a decent option because most of the functions of the C line still "work", in the sense that they do something quite useful, even if it is not entirely correct.
Steve jessop
source share