- fwrite (buf, 1, buflen, stream);
+ return fwrite (buf, 1, buflen, stream) == 0 ? -1 : 0;
+}
+
+/* Simple failure callback that prints an ASCII representation, using
+ the same notation as C99 strings. */
+int
+print_unicode_failure (unsigned int code, void *callback_arg)
+{
+ int e = errno;
+ FILE *stream = callback_arg;
+
+ fprintf (stream, code < 0x10000 ? "\\u%04X" : "\\U%08X", code);
+ errno = e;
+ return -1;