uniwidth.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Display width functions.
  2. Copyright (C) 2001-2002, 2005, 2007 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify it
  4. under the terms of the GNU General Public License as published
  5. by 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 GNU
  10. Lesser 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. #ifndef _UNIWIDTH_H
  14. #define _UNIWIDTH_H
  15. #include "unitypes.h"
  16. /* Get size_t. */
  17. #include <stddef.h>
  18. /* Get locale_charset() declaration. */
  19. #include "localcharset.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /* Display width. */
  24. /* These functions are locale dependent. The encoding argument identifies
  25. the encoding (e.g. "ISO-8859-2" for Polish). */
  26. /* Determine number of column positions required for UC. */
  27. extern int
  28. uc_width (ucs4_t uc, const char *encoding);
  29. /* Determine number of column positions required for first N units
  30. (or fewer if S ends before this) in S. */
  31. extern int
  32. u8_width (const uint8_t *s, size_t n, const char *encoding);
  33. extern int
  34. u16_width (const uint16_t *s, size_t n, const char *encoding);
  35. extern int
  36. u32_width (const uint32_t *s, size_t n, const char *encoding);
  37. /* Determine number of column positions required for S. */
  38. extern int
  39. u8_strwidth (const uint8_t *s, const char *encoding);
  40. extern int
  41. u16_strwidth (const uint16_t *s, const char *encoding);
  42. extern int
  43. u32_strwidth (const uint32_t *s, const char *encoding);
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif /* _UNIWIDTH_H */