uniwidth.in.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Display width functions.
  2. Copyright (C) 2001-2002, 2005, 2007, 2009-2013 Free Software Foundation,
  3. Inc.
  4. This program is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef _UNIWIDTH_H
  15. #define _UNIWIDTH_H
  16. #include "unitypes.h"
  17. /* Get size_t. */
  18. #include <stddef.h>
  19. /* Get locale_charset() declaration. */
  20. #include "localcharset.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Display width. */
  25. /* These functions are locale dependent. The encoding argument identifies
  26. the encoding (e.g. "ISO-8859-2" for Polish). */
  27. /* Determine number of column positions required for UC. */
  28. extern int
  29. uc_width (ucs4_t uc, const char *encoding)
  30. _UC_ATTRIBUTE_PURE;
  31. /* Determine number of column positions required for first N units
  32. (or fewer if S ends before this) in S. */
  33. extern int
  34. u8_width (const uint8_t *s, size_t n, const char *encoding)
  35. _UC_ATTRIBUTE_PURE;
  36. extern int
  37. u16_width (const uint16_t *s, size_t n, const char *encoding)
  38. _UC_ATTRIBUTE_PURE;
  39. extern int
  40. u32_width (const uint32_t *s, size_t n, const char *encoding)
  41. _UC_ATTRIBUTE_PURE;
  42. /* Determine number of column positions required for S. */
  43. extern int
  44. u8_strwidth (const uint8_t *s, const char *encoding)
  45. _UC_ATTRIBUTE_PURE;
  46. extern int
  47. u16_strwidth (const uint16_t *s, const char *encoding)
  48. _UC_ATTRIBUTE_PURE;
  49. extern int
  50. u32_strwidth (const uint32_t *s, const char *encoding)
  51. _UC_ATTRIBUTE_PURE;
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* _UNIWIDTH_H */