nls.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2020 Actions Corporation.
  3. * Copy from Linux
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. #ifndef _NLS_H_
  8. #define _NLS_H_
  9. #include <zephyr/types.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /* Unicode has changed over the years. Unicode code points no longer
  14. * fit into 16 bits; as of Unicode 5 valid code points range from 0
  15. * to 0x10ffff (17 planes, where each plane holds 65536 code points).
  16. *
  17. * The original decision to represent Unicode characters as 16-bit
  18. * wchar_t values is now outdated. But plane 0 still includes the
  19. * most commonly used characters, so we will retain it. The newer
  20. * 32-bit unicode_t type can be used when it is necessary to
  21. * represent the full Unicode character set.
  22. */
  23. /* Plane-0 Unicode character */
  24. #define MAX_WCHAR_T 0xffff
  25. /* Arbitrary Unicode character */
  26. typedef unsigned int unicode_t;
  27. /* nls_base.c */
  28. int utf8_to_utf32(const u8_t *s, int inlen, unicode_t *pu);
  29. int utf32_to_utf8(unicode_t u, u8_t *s, int maxout);
  30. /* nls_utf8.c */
  31. #ifdef CONFIG_NLS_UTF8
  32. int nls_utf8_uni2char(u16_t uni, u8_t *out, int boundlen);
  33. int nls_utf8_char2uni(const u8_t *rawstring, int boundlen, u16_t *uni);
  34. #endif
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif /* _NLS_H_ */