rendered paste body/* gcc -Wall -Werror $(pkg-config --cflags --libs glib-2.0) ./test-utf16.c */#include <glib.h>#include <string.h>int main (int argc, char **argv){ /* UTF16_BE string with a BOM */ const char utf16_be[] = { 0xfe, 0xff }; char *utf8; glong items_read; glong items_written; GError *error = NULL; /* on x86 machines, g_utf16_to_utf8 doesn't handle UTF16-BE strings so * this call is expected to fail and return NULL */ utf8 = g_utf16_to_utf8 ((const gunichar2 *)utf16_be, 1, &items_read, &items_written, &error); g_print ("read %ld unichar2, wrote %ld bytes, utf8 is %p (len: %zd)\n", items_read, items_written, utf8, strlen (utf8)); g_print ("error is %p\n", error); /* g_utf16_to_utf8 either returns NULL or a valid UTF8 string */ g_assert (g_utf8_validate (utf8, -1, NULL)); return 0;}