Browse Source

Add an iswblank compatibility API.

master
Reece H. Dunn 8 years ago
parent
commit
d585c77804
7 changed files with 45 additions and 1 deletions
  1. 4
    0
      CHANGELOG.md
  2. 2
    1
      README.md
  3. 13
    0
      src/ctype.c
  4. 17
    0
      src/include/ucd/ucd.h
  5. 3
    0
      tests/printcdata.c
  6. 3
    0
      tests/printucddata.c
  7. 3
    0
      tests/printucddata_cpp.cpp

+ 4
- 0
CHANGELOG.md View File

@@ -1,5 +1,9 @@
# Change Log

## 9.0.0.1 - (In Progress)

* Add `iswblank` compatibility.

## 9.0.0 - 2016-12-28

* Update to Unicode Character Data 9.0.0.

+ 2
- 1
README.md View File

@@ -96,6 +96,7 @@ The following character classification functions are provided:
|---------------|----------------|
| `ucd_isalnum` | `ucd::isalnum` |
| `ucd_isalpha` | `ucd::isalpha` |
| `ucd_isblank` | `ucd::isblank` |
| `ucd_iscntrl` | `ucd::iscntrl` |
| `ucd_isdigit` | `ucd::isdigit` |
| `ucd_isgraph` | `ucd::isgraph` |
@@ -105,7 +106,7 @@ The following character classification functions are provided:
| `ucd_isspace` | `ucd::isspace` |
| `ucd_isupper` | `ucd::isupper` |

__NOTE:__ Equivalents for `isblank` and `isxdigit` are not provided.
__NOTE:__ An equivalent for `isxdigit` is not provided.

## Build Dependencies


+ 13
- 0
src/ctype.c View File

@@ -53,6 +53,19 @@ int ucd_isalpha(codepoint_t c)
}
}

int ucd_isblank(codepoint_t c)
{
switch (ucd_lookup_category(c))
{
case UCD_CATEGORY_Zs:
return 1;
case UCD_CATEGORY_Cc:
return c == 0x09; // U+0009 : CHARACTER TABULATION
default:
return 0;
}
}

int ucd_iscntrl(codepoint_t c)
{
return ucd_lookup_category(c) == UCD_CATEGORY_Cc;

+ 17
- 0
src/include/ucd/ucd.h View File

@@ -339,6 +339,13 @@ int ucd_isalnum(codepoint_t c);
*/
int ucd_isalpha(codepoint_t c);

/** @brief Is the codepoint a tab or Unicode whitespace character?
*
* @param c The Unicode codepoint to check.
* @return Non-zero if the codepoint is a whitespace character, zero otherwise.
*/
int ucd_isblank(codepoint_t c);

/** @brief Is the codepoint a control character?
*
* @param c The Unicode codepoint to check.
@@ -776,6 +783,16 @@ namespace ucd
return ucd_isalpha(c);
}

/** @brief Is the codepoint a tab or Unicode whitespace character?
*
* @param c The Unicode codepoint to check.
* @return Non-zero if the codepoint is a whitespace character, zero otherwise.
*/
inline int isblank(codepoint_t c)
{
return ucd_isblank(c);
}

/** @brief Is the codepoint a control character?
*
* @param c The Unicode codepoint to check.

+ 3
- 0
tests/printcdata.c View File

@@ -114,6 +114,9 @@ void uprintf_is(FILE *out, codepoint_t c, char mode)
case 'a': // alpha
fputc(iswalpha(c) ? '1' : '0', out);
break;
case 'b': // blank
fputc(iswblank(c) ? '1' : '0', out);
break;
case 'c': // control
fputc(iswcntrl(c) ? '1' : '0', out);
break;

+ 3
- 0
tests/printucddata.c View File

@@ -111,6 +111,9 @@ void uprintf_is(FILE *out, codepoint_t c, char mode)
case 'a': // alpha
fputc(ucd_isalpha(c) ? '1' : '0', out);
break;
case 'b': // blank
fputc(ucd_isblank(c) ? '1' : '0', out);
break;
case 'c': // control
fputc(ucd_iscntrl(c) ? '1' : '0', out);
break;

+ 3
- 0
tests/printucddata_cpp.cpp View File

@@ -111,6 +111,9 @@ void uprintf_is(FILE *out, ucd::codepoint_t c, char mode)
case 'a': // alpha
fputc(ucd::isalpha(c) ? '1' : '0', out);
break;
case 'b': // blank
fputc(ucd::isblank(c) ? '1' : '0', out);
break;
case 'c': // control
fputc(ucd::iscntrl(c) ? '1' : '0', out);
break;

Loading…
Cancel
Save