Browse Source

Add an iswxdigit compatibility API.

master
Reece H. Dunn 8 years ago
parent
commit
34167771fd
7 changed files with 48 additions and 16 deletions
  1. 1
    1
      CHANGELOG.md
  2. 14
    15
      README.md
  3. 7
    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

+ 1
- 1
CHANGELOG.md View File

@@ -2,7 +2,7 @@

## 9.0.0.1 - (In Progress)

* Add `iswblank` compatibility.
* Add `iswblank` and `iswxdigit` compatibility.

## 9.0.0 - 2016-12-28


+ 14
- 15
README.md View File

@@ -92,21 +92,20 @@ C library provides a set of APIs that are compatible with `wctype.h`.

The following character classification functions are provided:

| C API | C++ API |
|---------------|----------------|
| `ucd_isalnum` | `ucd::isalnum` |
| `ucd_isalpha` | `ucd::isalpha` |
| `ucd_isblank` | `ucd::isblank` |
| `ucd_iscntrl` | `ucd::iscntrl` |
| `ucd_isdigit` | `ucd::isdigit` |
| `ucd_isgraph` | `ucd::isgraph` |
| `ucd_islower` | `ucd::islower` |
| `ucd_isprint` | `ucd::isprint` |
| `ucd_ispunct` | `ucd::ispunct` |
| `ucd_isspace` | `ucd::isspace` |
| `ucd_isupper` | `ucd::isupper` |

__NOTE:__ An equivalent for `isxdigit` is not provided.
| C API | C++ API |
|----------------|-----------------|
| `ucd_isalnum` | `ucd::isalnum` |
| `ucd_isalpha` | `ucd::isalpha` |
| `ucd_isblank` | `ucd::isblank` |
| `ucd_iscntrl` | `ucd::iscntrl` |
| `ucd_isdigit` | `ucd::isdigit` |
| `ucd_isgraph` | `ucd::isgraph` |
| `ucd_islower` | `ucd::islower` |
| `ucd_isprint` | `ucd::isprint` |
| `ucd_ispunct` | `ucd::ispunct` |
| `ucd_isspace` | `ucd::isspace` |
| `ucd_isupper` | `ucd::isupper` |
| `ucd_isxdigit` | `ucd::isxdigit` |

## Build Dependencies


+ 7
- 0
src/ctype.c View File

@@ -169,3 +169,10 @@ int ucd_isupper(codepoint_t c)
{
return ucd_lookup_category(c) == UCD_CATEGORY_Lu;
}

int ucd_isxdigit(codepoint_t c)
{
return (c >= 0x30 && c <= 0x39) // [0-9]
|| (c >= 0x41 && c <= 0x46) // [A-Z]
|| (c >= 0x61 && c <= 0x66); // [a-z]
}

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

@@ -402,6 +402,13 @@ int ucd_isspace(codepoint_t c);
*/
int ucd_isupper(codepoint_t c);

/** @brief Is the codepoint in the 'xdigit' class?
*
* @param c The Unicode codepoint to check.
* @return Non-zero if the codepoint is in the 'xdigit' class, zero otherwise.
*/
int ucd_isxdigit(codepoint_t c);

/** @brief Convert the Unicode codepoint to upper-case.
*
* This function only uses the simple case mapping present in the
@@ -873,6 +880,16 @@ namespace ucd
return ucd_isupper(c);
}

/** @brief Is the codepoint in the 'xdigit' class?
*
* @param c The Unicode codepoint to check.
* @return Non-zero if the codepoint is in the 'xdigit' class, zero otherwise.
*/
inline int isxdigit(codepoint_t c)
{
return ucd_isxdigit(c);
}

/** @brief Convert the Unicode codepoint to upper-case.
*
* This function only uses the simple case mapping present in the

+ 3
- 0
tests/printcdata.c View File

@@ -141,6 +141,9 @@ void uprintf_is(FILE *out, codepoint_t c, char mode)
case 'u': // upper case
fputc(iswupper(c) ? '1' : '0', out);
break;
case 'x': // xdigit
fputc(iswxdigit(c) ? '1' : '0', out);
break;
}
}


+ 3
- 0
tests/printucddata.c View File

@@ -138,6 +138,9 @@ void uprintf_is(FILE *out, codepoint_t c, char mode)
case 'u': // upper case
fputc(ucd_isupper(c) ? '1' : '0', out);
break;
case 'x': // xdigit
fputc(ucd_isxdigit(c) ? '1' : '0', out);
break;
}
}


+ 3
- 0
tests/printucddata_cpp.cpp View File

@@ -138,6 +138,9 @@ void uprintf_is(FILE *out, ucd::codepoint_t c, char mode)
case 'u': // upper case
fputc(ucd::isupper(c) ? '1' : '0', out);
break;
case 'x': // xdigit
fputc(ucd::isxdigit(c) ? '1' : '0', out);
break;
}
}


Loading…
Cancel
Save