mbswidth.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Determine the number of screen columns needed for a string.
  2. Copyright (C) 2000-2004, 2007, 2009-2013 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 <http://www.gnu.org/licenses/>. */
  13. #include <stddef.h>
  14. /* Avoid a clash of our mbswidth() with a function of the same name defined
  15. in UnixWare 7.1.1 <wchar.h>. We need this #include before the #define
  16. below.
  17. However, we don't want to #include <wchar.h> on all platforms because
  18. - Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
  19. <wchar.h>.
  20. - BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
  21. <wchar.h>. */
  22. #if HAVE_DECL_MBSWIDTH_IN_WCHAR_H
  23. # include <wchar.h>
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* Optional flags to influence mbswidth/mbsnwidth behavior. */
  29. /* If this bit is set, return -1 upon finding an invalid or incomplete
  30. character. Otherwise, assume invalid characters have width 1. */
  31. #define MBSW_REJECT_INVALID 1
  32. /* If this bit is set, return -1 upon finding a non-printable character.
  33. Otherwise, assume unprintable characters have width 0 if they are
  34. control characters and 1 otherwise. */
  35. #define MBSW_REJECT_UNPRINTABLE 2
  36. /* Returns the number of screen columns needed for STRING. */
  37. #define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */
  38. extern int mbswidth (const char *string, int flags);
  39. /* Returns the number of screen columns needed for the NBYTES bytes
  40. starting at BUF. */
  41. extern int mbsnwidth (const char *buf, size_t nbytes, int flags);
  42. #ifdef __cplusplus
  43. }
  44. #endif