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