What is the difference between glich gunichar and wchar_t and which is better for cross-platform solutions?

I am trying to write some C code that is portable only if the user has gcc and glib installed.

From all my research, I found that with gcc a wchar_t always defined as 4 bytes, and with glib a gunichar also 4 bytes.

Which I did not have , since, for example, like gunichar , a wchar_t is encoded as UCS4. This is true? If so, I should just highlight a gunichar* in wchar_t* and use the stdc wcs* functions, right?

+5
source share
1 answer

If you use GLib, do not use wchar_t . Use its unicode support, it is much better than the standard C library support.

wchar_t - 4 bytes on Linux and Mac OS (and several others), and not on Windows (these are 2 bytes) and some others. Portable code means avoiding wchar_t like a plague.

+8
source

Source: https://habr.com/ru/post/988720/


All Articles