chars.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* classes: h_files */
  2. #ifndef SCM_CHARS_H
  3. #define SCM_CHARS_H
  4. /* Copyright (C) 1995,1996,2000,2001,2004, 2006, 2008, 2009 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. */
  21. #include "libguile/__scm.h"
  22. #ifndef SCM_T_WCHAR_DEFINED
  23. typedef scm_t_int32 scm_t_wchar;
  24. #define SCM_T_WCHAR_DEFINED
  25. #endif /* SCM_T_WCHAR_DEFINED */
  26. /* Immediate Characters
  27. */
  28. #define SCM_CHARP(x) (SCM_ITAG8(x) == scm_tc8_char)
  29. #define SCM_CHAR(x) ((scm_t_wchar)SCM_ITAG8_DATA(x))
  30. /* SCM_MAKE_CHAR maps signed chars (-128 to 127) and unsigned chars (0
  31. to 255) to Latin-1 codepoints (0 to 255) while allowing higher
  32. codepoints (256 to 1114111) to pass through unchanged.
  33. This macro evaluates x twice, which may lead to side effects if not
  34. used properly. */
  35. #define SCM_MAKE_CHAR(x) \
  36. ((x) <= 1 \
  37. ? SCM_MAKE_ITAG8 ((scm_t_bits) (unsigned char) (x), scm_tc8_char) \
  38. : SCM_MAKE_ITAG8 ((scm_t_bits) (x), scm_tc8_char))
  39. #define SCM_CODEPOINT_DOTTED_CIRCLE (0x25cc)
  40. #define SCM_CODEPOINT_SURROGATE_START (0xd800)
  41. #define SCM_CODEPOINT_SURROGATE_END (0xdfff)
  42. #define SCM_CODEPOINT_MAX (0x10ffff)
  43. #define SCM_IS_UNICODE_CHAR(c) \
  44. (((scm_t_wchar) (c) >= 0 \
  45. && (scm_t_wchar) (c) < SCM_CODEPOINT_SURROGATE_START) \
  46. || ((scm_t_wchar) (c) > SCM_CODEPOINT_SURROGATE_END \
  47. && (scm_t_wchar) (c) <= SCM_CODEPOINT_MAX))
  48. SCM_API SCM scm_char_p (SCM x);
  49. SCM_API SCM scm_char_eq_p (SCM x, SCM y);
  50. SCM_API SCM scm_char_less_p (SCM x, SCM y);
  51. SCM_API SCM scm_char_leq_p (SCM x, SCM y);
  52. SCM_API SCM scm_char_gr_p (SCM x, SCM y);
  53. SCM_API SCM scm_char_geq_p (SCM x, SCM y);
  54. SCM_API SCM scm_char_ci_eq_p (SCM x, SCM y);
  55. SCM_API SCM scm_char_ci_less_p (SCM x, SCM y);
  56. SCM_API SCM scm_char_ci_leq_p (SCM x, SCM y);
  57. SCM_API SCM scm_char_ci_gr_p (SCM x, SCM y);
  58. SCM_API SCM scm_char_ci_geq_p (SCM x, SCM y);
  59. SCM_API SCM scm_char_alphabetic_p (SCM chr);
  60. SCM_API SCM scm_char_numeric_p (SCM chr);
  61. SCM_API SCM scm_char_whitespace_p (SCM chr);
  62. SCM_API SCM scm_char_upper_case_p (SCM chr);
  63. SCM_API SCM scm_char_lower_case_p (SCM chr);
  64. SCM_API SCM scm_char_is_both_p (SCM chr);
  65. SCM_API SCM scm_char_to_integer (SCM chr);
  66. SCM_API SCM scm_integer_to_char (SCM n);
  67. SCM_API SCM scm_char_upcase (SCM chr);
  68. SCM_API SCM scm_char_downcase (SCM chr);
  69. SCM_API SCM scm_char_titlecase (SCM chr);
  70. SCM_API SCM scm_char_general_category (SCM chr);
  71. SCM_API scm_t_wchar scm_c_upcase (scm_t_wchar c);
  72. SCM_API scm_t_wchar scm_c_downcase (scm_t_wchar c);
  73. SCM_API scm_t_wchar scm_c_titlecase (scm_t_wchar c);
  74. SCM_INTERNAL const char *scm_i_charname (SCM chr);
  75. SCM_INTERNAL SCM scm_i_charname_to_char (const char *charname,
  76. size_t charname_len);
  77. SCM_INTERNAL void scm_init_chars (void);
  78. #endif /* SCM_CHARS_H */
  79. /*
  80. Local Variables:
  81. c-file-style: "gnu"
  82. End:
  83. */