]> code.delx.au - gnu-emacs/blobdiff - src/character.c
Improve [:alpha:] and [:alnum:] for multibyte characters (Bug#19878)
[gnu-emacs] / src / character.c
index 39d32c9d41af9e8296eefea2e476139a9a61f9b5..999f99aa0030c0416c1ffcf721b023401007625e 100644 (file)
@@ -984,6 +984,48 @@ character is not ASCII nor 8-bit character, an error is signaled.  */)
 
 #ifdef emacs
 
+/* Return 'true' if C is an alphabetic character as defined by its
+   Unicode properties.  */
+bool
+alphabeticp (int c)
+{
+  Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c);
+
+  if (INTEGERP (category))
+    {
+      unicode_category_t gen_cat = XINT (category);
+
+      /* See UTS #18.  There are additional characters that should be
+        here, those designated as Other_uppercase, Other_lowercase,
+        and Other_alphabetic; FIXME.  */
+      return (gen_cat == UNICODE_CATEGORY_Lu
+             || gen_cat == UNICODE_CATEGORY_Ll
+             || gen_cat == UNICODE_CATEGORY_Lt
+             || gen_cat == UNICODE_CATEGORY_Lm
+             || gen_cat == UNICODE_CATEGORY_Lo
+             || gen_cat == UNICODE_CATEGORY_Mn
+             || gen_cat == UNICODE_CATEGORY_Mc
+             || gen_cat == UNICODE_CATEGORY_Me
+             || gen_cat == UNICODE_CATEGORY_Nl) ? true : false;
+    }
+}
+
+/* Return 'true' if C is an decimal-number character as defined by its
+   Unicode properties.  */
+bool
+decimalnump (int c)
+{
+  Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c);
+
+  if (INTEGERP (category))
+    {
+      unicode_category_t gen_cat = XINT (category);
+
+      /* See UTS #18.  */
+      return (gen_cat == UNICODE_CATEGORY_Nd) ? true : false;
+    }
+}
+
 void
 syms_of_character (void)
 {