mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Better range check for codepoints
* libguile/chars.h (SCM_IS_UNICODE_CHAR): check for negative codepoints
This commit is contained in:
parent
6d736fdba2
commit
526ee76ac3
1 changed files with 6 additions and 2 deletions
|
@ -48,9 +48,13 @@ typedef scm_t_int32 scm_t_wchar;
|
|||
: SCM_MAKE_ITAG8 ((scm_t_bits) (x), scm_tc8_char))
|
||||
|
||||
#define SCM_CODEPOINT_MAX (0x10ffff)
|
||||
#define SCM_CODEPOINT_SURROGATE_START (0xd800)
|
||||
#define SCM_CODEPOINT_SURROGATE_END (0xdfff)
|
||||
#define SCM_IS_UNICODE_CHAR(c) \
|
||||
((scm_t_wchar) (c) <= 0xd7ff \
|
||||
|| ((scm_t_wchar) (c) >= 0xe000 && (scm_t_wchar) (c) <= SCM_CODEPOINT_MAX))
|
||||
(((scm_t_wchar) (c) >= 0 \
|
||||
&& (scm_t_wchar) (c) < SCM_CODEPOINT_SURROGATE_START) \
|
||||
|| ((scm_t_wchar) (c) > SCM_CODEPOINT_SURROGATE_END \
|
||||
&& (scm_t_wchar) (c) <= SCM_CODEPOINT_MAX))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue