# ilib-ctype

> Common utility functions for ilib. iLib is a cross-engine library of internationalization (i18n) classes written in pure JS

Latest version **1.4.0** (published 2026-08-27) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ilib-ctype
pnpm add ilib-ctype
yarn add ilib-ctype
bun add ilib-ctype
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2026-08-27 |
| First published | 2021-04-27 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=12 <23 |
| Dependencies | 1 |
| Unpacked size | 959.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 7 |
| Author | Edwin Hoogerbeets |
| Maintainers | ehoogerbeets |
| Keywords | internationalization, i18n, localization, l10n, globalization, g11n, date, time, format, locale, translation |

## Links

- npm: https://www.npmjs.com/package/ilib-ctype
- Repository: https://github.com/iLib-js/ilib-mono
- Homepage: https://github.com/iLib-js/ilib-mono/blob/main/packages/ilib-ctype
- Issues: https://github.com/iLib-js/ilib-mono/issues
- npm.io page: https://npm.io/package/ilib-ctype

## Dependencies (1)

- [ilib-common](https://npm.io/package/ilib-common.md) ^1.1.7

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 1.4.0 (latest) — 2026-08-27
- 1.3.0 — 2025-09-09
- 1.2.2 — 2025-01-15
- 1.2.1 — 2024-01-25
- 1.2.0 — 2023-11-22
- 1.1.0 — 2022-09-13
- 1.0.0 — 2021-04-27

## README

# ilib-ctype

Utility functions for dealing with character types.

## Installation

```
npm install ilib-ctype

or

yarn add ilib-ctype
```

## CType Functions

The CType functions are modeled after the posix ctype functions for C/C++.
The data for all of the CType functions are derived from the Unicode
Character Database so that they can be called with any character in
Unicode. (Many posix implementations do not support Unicode!)

Because Javascript does not have an intrinsic character type, the arguments
for these functions are strings. Only the very first character in the
string is examined to determine the output of the function. The rest of
the string is ignored.

The functions are as follows:

- isAlnum - is the character alpha numeric?
- isAlpha - is the character alphabetic?
- isAscii - is the character part of the ASCII subset?
- isBlank - is the character blank?
- isCntrl - is the character a control character?
- isDigit - is the character a digit?
- isGraph - is the character a graphic character?
- isIdeo - is the character an ideographic (Asian) character?
- isLower - is the character lower-case? For scripts that do not have
  the concept of cases, this always returns true.
- isPrint - is the character printable on the screen?
- isPunct - is the character a punctuation character?
- isScript - does the given character belong to the named script?
- isSpace - is the character a whitespace character?
- isUpper - is the character upper-case? For scripts that do not have
  the concept of case, this always returns true.
- isXdigit - is this character a hexadecimal digit?

Additionally, there is a `withinRange()` function which returns
true if the given character is within the named Unicode range.

```javascript
import { withinRange } from "ilib-ctype";

console.log(withinRange("\uFE2A", "HalfMarks")); // prints true
```

There is also a `hasUCDCharProperty()` function which returns true
if a character has a given Unicode general-category property. You
may pass either the short code (`"Mn"`) or the long Unicode name
(`"Nonspacing_Mark"`):

```javascript
import { hasUCDCharProperty } from "ilib-ctype";

console.log(hasUCDCharProperty("\u0308", "Nonspacing_Mark")); // true
console.log(hasUCDCharProperty(0x093E, "Mc")); // true (Spacing_Mark)
```

## Using the CType Functions

All of the functions are exported from the package in general. Here is
an example of how you would use the `isAlpha` function.

```javascript
import { isAlpha } from "ilib-ctype";

console.log(isAlpha("a")); // prints true
console.log(isAlpha("3")); // prints false
```

If you are using this package in a webpack bundle, make sure to
only import the ctype functions you need in order to minimize
the final size of your bundle. That is, do not `import *` as that
will bring in a bunch of data that you probably don't need. Tree
shaking in the latest webpack will ensure that only the data needed
for the functions you are using will be included in your bundle.

## License

Copyright © 2021-2026, JEDLSoft

This package is released under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0). The full license text is available in the [LICENSE](https://github.com/iLib-js/ilib-mono/blob/main/packages/ilib-ctype/LICENSE) file in the ilib-mono repository on GitHub.

## Release Notes

See [CHANGELOG.md](https://github.com/iLib-js/ilib-mono/blob/main/packages/ilib-ctype/CHANGELOG.md).

---
_Source: https://npm.io/package/ilib-ctype · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
