unicodeio.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Unicode character output to streams with locale dependent encoding.
  2. Copyright (C) 2000-2003, 2005, 2008-2020 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  13. #ifndef UNICODEIO_H
  14. # define UNICODEIO_H
  15. # include <stddef.h>
  16. # include <stdio.h>
  17. /* Converts the Unicode character CODE to its multibyte representation
  18. in the current locale and calls the SUCCESS callback on the resulting
  19. byte sequence. If an error occurs, invokes the FAILURE callback instead,
  20. passing it CODE and an English error string.
  21. Returns whatever the callback returned.
  22. Assumes that the locale doesn't change between two calls. */
  23. extern long unicode_to_mb (unsigned int code,
  24. long (*success) (const char *buf, size_t buflen,
  25. void *callback_arg),
  26. long (*failure) (unsigned int code, const char *msg,
  27. void *callback_arg),
  28. void *callback_arg);
  29. /* Outputs the Unicode character CODE to the output stream STREAM.
  30. Upon failure, exit if exit_on_error is true, otherwise output a fallback
  31. notation. */
  32. extern void print_unicode_char (FILE *stream, unsigned int code,
  33. int exit_on_error);
  34. /* Simple success callback that outputs the converted string.
  35. The STREAM is passed as callback_arg. */
  36. extern long fwrite_success_callback (const char *buf, size_t buflen,
  37. void *callback_arg);
  38. #endif