utf.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. enum
  26. {
  27. UTFmax = 4, /* maximum bytes per rune */
  28. Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
  29. Runeself = 0x80, /* rune and UTF sequences are the same (<) */
  30. Runeerror = 0xFFFD, /* decoding error in UTF */
  31. Runemax = 0x10FFFF, /* maximum rune value */
  32. };
  33. int chartorune(Rune *rune, const char *str);
  34. int runetochar(char *str, const Rune *rune);
  35. int runelen(int c);
  36. int isalpharune(Rune c);
  37. int islowerrune(Rune c);
  38. int isupperrune(Rune c);
  39. Rune tolowerrune(Rune c);
  40. Rune toupperrune(Rune c);
  41. #endif