utf.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #ifndef _UTF_H_
  10. #define _UTF_H_ 1
  11. #pragma lib "/$M/lib/ape/libutf.a"
  12. #pragma src "/sys/src/ape/lib/utf"
  13. #if defined(__cplusplus)
  14. extern "C" {
  15. #endif
  16. typedef unsigned int Rune; /* 32 bits */
  17. enum
  18. {
  19. UTFmax = 4, /* maximum bytes per rune */
  20. Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
  21. Runeself = 0x80, /* rune and UTF sequences are the same (<) */
  22. Runeerror = 0xFFFD, /* decoding error in UTF */
  23. Runemax = 0x10FFFF, /* 21-bit rune */
  24. };
  25. /*
  26. * rune routines
  27. */
  28. extern int runetochar(char*, Rune*);
  29. extern int chartorune(Rune*, char*);
  30. extern int runelen(int32_t);
  31. extern int runenlen(Rune*, int);
  32. extern int fullrune(char*, int);
  33. extern int utflen(char*);
  34. extern int utfnlen(char*, int32_t);
  35. extern char* utfrune(char*, int32_t);
  36. extern char* utfrrune(char*, int32_t);
  37. extern char* utfutf(char*, char*);
  38. extern char* utfecpy(char*, char*, char*);
  39. extern Rune* runestrcat(Rune*, Rune*);
  40. extern Rune* runestrchr(Rune*, Rune);
  41. extern int runestrcmp(Rune*, Rune*);
  42. extern Rune* runestrcpy(Rune*, Rune*);
  43. extern Rune* runestrncpy(Rune*, Rune*, int32_t);
  44. extern Rune* runestrecpy(Rune*, Rune*, Rune*);
  45. extern Rune* runestrdup(Rune*);
  46. extern Rune* runestrncat(Rune*, Rune*, int32_t);
  47. extern int runestrncmp(Rune*, Rune*, int32_t);
  48. extern Rune* runestrrchr(Rune*, Rune);
  49. extern int32_t runestrlen(Rune*);
  50. extern Rune* runestrstr(Rune*, Rune*);
  51. extern Rune tolowerrune(Rune);
  52. extern Rune totitlerune(Rune);
  53. extern Rune toupperrune(Rune);
  54. extern int isalpharune(Rune);
  55. extern int islowerrune(Rune);
  56. extern int isspacerune(Rune);
  57. extern int istitlerune(Rune);
  58. extern int isupperrune(Rune);
  59. #if defined(__cplusplus)
  60. }
  61. #endif
  62. #endif