@@ -122,6 +122,7 @@ src_libucd_la_SOURCES = \ | |||
src/case.c \ | |||
src/categories.c \ | |||
src/ctype.c \ | |||
src/proplist.c \ | |||
src/scripts.c \ | |||
src/tostring.c | |||
@@ -325,6 +325,21 @@ const char *ucd_get_script_string(ucd_script s); | |||
*/ | |||
ucd_script ucd_lookup_script(codepoint_t c); | |||
/** @brief Properties | |||
*/ | |||
typedef enum ucd_property_ | |||
{ | |||
UCD_PROPERTY_WHITE_SPACE = 0x0001, /**< @brief White_Space */ | |||
} ucd_property; | |||
/** @brief Return the properties of the specified codepoint. | |||
* | |||
* @param c The Unicode codepoint to lookup. | |||
* @param category The General Category of the codepoint. | |||
* @return The properties associated with the codepoint. | |||
*/ | |||
ucd_property ucd_properties(codepoint_t c, ucd_category category); | |||
/** @brief Is the codepoint in the 'alnum' class? | |||
* | |||
* @param c The Unicode codepoint to check. | |||
@@ -770,6 +785,24 @@ namespace ucd | |||
return (script)ucd_lookup_script(c); | |||
} | |||
/** @brief Properties | |||
*/ | |||
enum property | |||
{ | |||
White_Space = UCD_PROPERTY_WHITE_SPACE, /**< @brief White_Space */ | |||
}; | |||
/** @brief Return the properties of the specified codepoint. | |||
* | |||
* @param c The Unicode codepoint to lookup. | |||
* @param cat The General Category of the codepoint. | |||
* @return The properties associated with the codepoint. | |||
*/ | |||
inline property properties(codepoint_t c, category cat) | |||
{ | |||
return (property)ucd_properties(c, (ucd_category)cat); | |||
} | |||
/** @brief Is the codepoint in the 'alnum' class? | |||
* | |||
* @param c The Unicode codepoint to check. |
@@ -0,0 +1,46 @@ | |||
/* PropList APIs. | |||
* | |||
* Copyright (C) 2017 Reece H. Dunn | |||
* | |||
* This file is part of ucd-tools. | |||
* | |||
* ucd-tools is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* ucd-tools is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with ucd-tools. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
#include "ucd/ucd.h" | |||
ucd_property ucd_properties(codepoint_t c, ucd_category category) | |||
{ | |||
switch (category) | |||
{ | |||
case UCD_CATEGORY_Cc: | |||
switch (c) | |||
{ | |||
case 0x09: // CHARACTER TABULATION | |||
case 0x0A: // LINE FEED | |||
case 0x0B: // LINE TABULATION | |||
case 0x0C: // FORM FEED | |||
case 0x0D: // CARRIAGE RETURN | |||
case 0x85: // NEXT LINE | |||
return UCD_PROPERTY_WHITE_SPACE; | |||
} | |||
return 0; | |||
case UCD_CATEGORY_Zl: | |||
case UCD_CATEGORY_Zp: | |||
case UCD_CATEGORY_Zs: | |||
return UCD_PROPERTY_WHITE_SPACE; | |||
default: | |||
return 0; | |||
}; | |||
} |