diff options
author | Julian Graham <julian.graham@aya.yale.edu> | 2009-12-24 00:25:19 -0500 |
---|---|---|
committer | Julian Graham <julian.graham@aya.yale.edu> | 2009-12-24 11:55:47 -0500 |
commit | 0ca3a342d19ec89b8ae6bba0a74f0f9ecc5cf7c2 (patch) | |
tree | 551524af48bba7fa5fd174f1129b3ba2216deeeb /libguile/chars.c | |
parent | d7a4096d251933a21325739fcd32129b073c33ce (diff) | |
download | guile-0ca3a342d19ec89b8ae6bba0a74f0f9ecc5cf7c2.tar.gz |
Support for Unicode general categories
* libguile/chars.c, libguile/chars.h (scm_char_general_category): New function.
* test-suite/tests/chars.test: Unit tests for `char-general-category'.
* doc/ref/api-data.texi (Characters): Documentation for
`char-general-category'.
Diffstat (limited to 'libguile/chars.c')
-rw-r--r-- | libguile/chars.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libguile/chars.c b/libguile/chars.c index 1c4d10609..16a2b90d6 100644 --- a/libguile/chars.c +++ b/libguile/chars.c @@ -25,6 +25,7 @@ #include <ctype.h> #include <limits.h> #include <unicase.h> +#include <unictype.h> #include "libguile/_scm.h" #include "libguile/validate.h" @@ -467,6 +468,25 @@ SCM_DEFINE (scm_char_titlecase, "char-titlecase", 1, 0, 0, } #undef FUNC_NAME +SCM_DEFINE (scm_char_general_category, "char-general-category", 1, 0, 0, + (SCM chr), + "Return a symbol representing the Unicode general category of " + "@var{chr} or @code{#f} if a named category cannot be found.") +#define FUNC_NAME s_scm_char_general_category +{ + const char *sym; + uc_general_category_t cat; + + SCM_VALIDATE_CHAR (1, chr); + cat = uc_general_category (SCM_CHAR (chr)); + sym = uc_general_category_name (cat); + + if (sym != NULL) + return scm_from_locale_symbol (sym); + return SCM_BOOL_F; +} +#undef FUNC_NAME + |