mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-24 04:23:44 +00:00
Add ctype-style APIs that are compatible with wctype.h.
This commit is contained in:
+2
-1
@@ -68,4 +68,5 @@ lib_LTLIBRARIES += src/libucd.la
|
||||
src_libucd_la_LDFLAGS = -version-info $(LIBUCD_VERSION)
|
||||
src_libucd_la_CXXFLAGS = ${AM_CXXFLAGS}
|
||||
src_libucd_la_SOURCES = \
|
||||
src/categories.cpp
|
||||
src/categories.cpp \
|
||||
src/ctype.cpp
|
||||
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/* ctype-style APIs.
|
||||
*
|
||||
* Copyright (C) 2012 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/>.
|
||||
*/
|
||||
|
||||
// NOTE: This file is automatically generated from the UnicodeData.txt file in
|
||||
// the Unicode Character database by the ucd-tools/tools/categories.py script.
|
||||
|
||||
#include "ucd/ucd.h"
|
||||
|
||||
int ucd::isalnum(codepoint_t c)
|
||||
{
|
||||
switch (lookup_category(c))
|
||||
{
|
||||
case Ll: case Lm: case Lo: case Lt: case Lu:
|
||||
case Nd: case Nl: case No:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ucd::isalpha(codepoint_t c)
|
||||
{
|
||||
switch (lookup_category(c))
|
||||
{
|
||||
case Ll: case Lm: case Lo: case Lt: case Lu:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ucd::iscntrl(codepoint_t c)
|
||||
{
|
||||
switch (lookup_category(c))
|
||||
{
|
||||
case Cc: case Zc:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ucd::isdigit(codepoint_t c)
|
||||
{
|
||||
switch (lookup_category(c))
|
||||
{
|
||||
case Nd: case Nl: case No:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ucd::isgraph(codepoint_t c)
|
||||
{
|
||||
switch (lookup_category(c))
|
||||
{
|
||||
case Cc: case Cf: case Ci: case Cn: case Co: case Cs:
|
||||
case Zc: case Zl: case Zp: case Zs:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ucd::islower(codepoint_t c)
|
||||
{
|
||||
return lookup_category(c) == Ll;
|
||||
}
|
||||
|
||||
int ucd::isprint(codepoint_t c)
|
||||
{
|
||||
switch (lookup_category(c))
|
||||
{
|
||||
case Cc: case Cf: case Ci: case Cn: case Co: case Cs:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ucd::ispunct(codepoint_t c)
|
||||
{
|
||||
switch (lookup_category(c))
|
||||
{
|
||||
case Pc: case Pd: case Pe: case Pf: case Pi: case Po: case Ps:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ucd::isspace(codepoint_t c)
|
||||
{
|
||||
switch (lookup_category(c))
|
||||
{
|
||||
case Zc: case Zl: case Zp: case Zs:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ucd::isupper(codepoint_t c)
|
||||
{
|
||||
return lookup_category(c) == Lu;
|
||||
}
|
||||
@@ -96,6 +96,86 @@ namespace ucd
|
||||
* @return The General Category of the Unicode codepoint.
|
||||
*/
|
||||
category lookup_category(codepoint_t c);
|
||||
|
||||
|
||||
/** @name ctype-style APIs
|
||||
* @brief These functions provide wctype compatible functions using the UCD data.
|
||||
*/
|
||||
//@{
|
||||
|
||||
|
||||
/** @brief Is the codepoint an alpha-numeric character?
|
||||
*
|
||||
* @param c The Unicode codepoint to check.
|
||||
* @return Non-zero if the codepoint is a letter or number, zero otherwise.
|
||||
*/
|
||||
int isalnum(codepoint_t c);
|
||||
|
||||
/** @brief Is the codepoint a letter?
|
||||
*
|
||||
* @param c The Unicode codepoint to check.
|
||||
* @return Non-zero if the codepoint is a letter, zero otherwise.
|
||||
*/
|
||||
int isalpha(codepoint_t c);
|
||||
|
||||
/** @brief Is the codepoint a control character?
|
||||
*
|
||||
* @param c The Unicode codepoint to check.
|
||||
* @return Non-zero if the codepoint is a control character, zero otherwise.
|
||||
*/
|
||||
int iscntrl(codepoint_t c);
|
||||
|
||||
/** @brief Is the codepoint a numeric character?
|
||||
*
|
||||
* @param c The Unicode codepoint to check.
|
||||
* @return Non-zero if the codepoint is a number, zero otherwise.
|
||||
*/
|
||||
int isdigit(codepoint_t c);
|
||||
|
||||
/** @brief Does the codepoint have a displayable glyph?
|
||||
*
|
||||
* @param c The Unicode codepoint to check.
|
||||
* @return Non-zero if the codepoint has a displayable glyph, zero otherwise.
|
||||
*/
|
||||
int isgraph(codepoint_t c);
|
||||
|
||||
/** @brief Is the codepoint a lower-case letter?
|
||||
*
|
||||
* @param c The Unicode codepoint to check.
|
||||
* @return Non-zero if the codepoint is a lower-case letter, zero otherwise.
|
||||
*/
|
||||
int islower(codepoint_t c);
|
||||
|
||||
/** @brief Is the codepoint a printable character?
|
||||
*
|
||||
* @param c The Unicode codepoint to check.
|
||||
* @return Non-zero if the codepoint is a printable character, zero otherwise.
|
||||
*/
|
||||
int isprint(codepoint_t c);
|
||||
|
||||
/** @brief Is the codepoint a punctuation character?
|
||||
*
|
||||
* @param c The Unicode codepoint to check.
|
||||
* @return Non-zero if the codepoint is a punctuation character, zero otherwise.
|
||||
*/
|
||||
int ispunct(codepoint_t c);
|
||||
|
||||
/** @brief Is the codepoint a whitespace character?
|
||||
*
|
||||
* @param c The Unicode codepoint to check.
|
||||
* @return Non-zero if the codepoint is a whitespace character, zero otherwise.
|
||||
*/
|
||||
int isspace(codepoint_t c);
|
||||
|
||||
/** @brief Is the codepoint an upper-case letter?
|
||||
*
|
||||
* @param c The Unicode codepoint to check.
|
||||
* @return Non-zero if the codepoint is an upper-case letter, zero otherwise.
|
||||
*/
|
||||
int isupper(codepoint_t c);
|
||||
|
||||
|
||||
//@}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user