-# define UTF8_NAME "UTF-8"
-
-/* Place into BUF the locale-dependent representation of the character
- CODE. Return the size of the result. If there is a conversion
- error, return -1, setting errno appropriately. Assumes that the
- locale doesn't change between two calls. */
-static size_t
-convert_unicode_char (char buf[MB_LEN_MAX], unsigned int code)
+#define UTF8_NAME "UTF-8"
+
+/* Converts the Unicode character CODE to its multibyte representation
+ in the current locale and calls the SUCCESS callback on the resulting
+ byte sequence. If an error occurs, invokes the FAILURE callback instead,
+ passing it CODE and an English error string.
+ Returns whatever the callback returned.
+ Assumes that the locale doesn't change between two calls. */
+long
+unicode_to_mb (unsigned int code,
+ long (*success) (const char *buf, size_t buflen,
+ void *callback_arg),
+ long (*failure) (unsigned int code, const char *msg,
+ void *callback_arg),
+ void *callback_arg)