utf.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * The authors of this software are Rob Pike and Ken Thompson.
  3. * Copyright (c) 2002 by Lucent Technologies.
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose without fee is hereby granted, provided that this entire notice
  6. * is included in all copies of any software which is or includes a copy
  7. * or modification of this software and in all copies of the supporting
  8. * documentation for such software.
  9. * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
  10. * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE
  11. * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  12. * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  13. */
  14. #ifndef js_utf_h
  15. #define js_utf_h
  16. typedef int Rune; /* 32 bits */
  17. #define chartorune jsU_chartorune
  18. #define runetochar jsU_runetochar
  19. #define runelen jsU_runelen
  20. #define isalpharune jsU_isalpharune
  21. #define islowerrune jsU_islowerrune
  22. #define isupperrune jsU_isupperrune
  23. #define tolowerrune jsU_tolowerrune
  24. #define toupperrune jsU_toupperrune
  25. #define tolowerrune_full jsU_tolowerrune_full
  26. #define toupperrune_full jsU_toupperrune_full
  27. enum
  28. {
  29. UTFmax = 4, /* maximum bytes per rune */
  30. Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
  31. Runeself = 0x80, /* rune and UTF sequences are the same (<) */
  32. Runeerror = 0xFFFD, /* decoding error in UTF */
  33. Runemax = 0x10FFFF, /* maximum rune value */
  34. };
  35. int chartorune(Rune *rune, const char *str);
  36. int runetochar(char *str, const Rune *rune);
  37. int runelen(int c);
  38. int isalpharune(Rune c);
  39. int islowerrune(Rune c);
  40. int isupperrune(Rune c);
  41. Rune tolowerrune(Rune c);
  42. Rune toupperrune(Rune c);
  43. const Rune* tolowerrune_full(Rune c);
  44. const Rune* toupperrune_full(Rune c);
  45. #endif