https://github.com/artichoke/posix-space
🔠Determine if a byte is a space in the POSIX locale
https://github.com/artichoke/posix-space
artichoke locale posix rust rust-crate
Last synced: 6 months ago
JSON representation
🔠Determine if a byte is a space in the POSIX locale
- Host: GitHub
- URL: https://github.com/artichoke/posix-space
- Owner: artichoke
- License: mit
- Created: 2022-08-13T04:50:52.000Z (about 3 years ago)
- Default Branch: trunk
- Last Pushed: 2025-04-01T00:23:33.000Z (6 months ago)
- Last Synced: 2025-04-01T01:28:03.064Z (6 months ago)
- Topics: artichoke, locale, posix, rust, rust-crate
- Language: Rust
- Homepage: https://crates.io/crates/posix-space
- Size: 1.74 MB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# posix-space
[](https://github.com/artichoke/posix-space/actions)
[](https://codecov.artichokeruby.org/posix-space/index.html)
[](https://discord.gg/QCe2tp2)
[](https://twitter.com/artichokeruby)
[](https://crates.io/crates/posix-space)
[](https://docs.rs/posix-space)
[](https://artichoke.github.io/posix-space/posix_space/)A small crate which determines if a byte is classified as a space in the POSIX
locale per [POSIX.1-2017], chapter 7, [Locale].[posix.1-2017]: https://pubs.opengroup.org/onlinepubs/9699919799/mindex.html
[locale]:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html> **space**
>
> Define characters to be classified as white-space characters.
>
> In the POSIX locale, exactly \, \, \,
> \, \, and \ shall be included.The function defined in this crate should have equivalent behavior to the C
function [`isspace`] as defined in `ctype.h`.[`isspace`]: https://linux.die.net/man/3/isspace
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
posix-space = "1.0.4"
```Then classify bytes like:
```rust
assert!(posix_space::is_space(b' '));
assert!(posix_space::is_space(b'\t'));
assert!(posix_space::is_space(b'\r'));assert!(!posix_space::is_space(b'\0'));
assert!(!posix_space::is_space(b'C'));
assert!(!posix_space::is_space(b'&'));
```This crate's behavior differs from [`u8::is_ascii_whitespace`] in the Rust
standard library in that \, `\x0B`, is considered a **space**.[`u8::is_ascii_whitespace`]:
https://doc.rust-lang.org/stable/std/primitive.u8.html#method.is_ascii_whitespace```rust
assert!(posix_space::is_space(b'\x0B'));
```## Crate features
`posix-space` is `no_std` with no dependencies outside of Rust [`core`].
### Minimum Supported Rust Version
This crate requires at least Rust 1.31.0. This version can be bumped in minor
releases.## License
`posix-space` is licensed under the [MIT License](LICENSE) (c) Ryan Lopopolo.
[`core`]: https://doc.rust-lang.org/stable/core/