#utf-8 #unicode #character #no-alloc

无 std utf8-parser

一次解析一个字节的 UTF-8 解析器

2 个版本

0.0.4 2023 年 12 月 16 日
0.0.3 2023 年 12 月 14 日

#185无标准库

MIT/Apache

20KB
350

utf8-parser

一个具有状态的、一次解析一个字节的 UTF-8 解析器。这适用于从 UART 读取的字节构建字符等情况。

Repository crates.io Documentation

示例

use utf8_parser::Utf8Parser;

let mut parser = Utf8Parser::new();
assert!(parser.push(0xf0).unwrap().is_none());
assert!(parser.push(0x9f).unwrap().is_none());
assert!(parser.push(0x8e).unwrap().is_none());
assert_eq!(parser.push(0x84).unwrap(), Some('🎄'));

包功能

  • std - 在 Utf8ParserError 上启用 std::error::Error 实现
  • error_in_core - 与 std 相同,但使用 core::error::Error。目前需要 Nightly 和 #![feature(error_in_core)]。如果启用了 std 功能,则没有效果。

类似包

许可证

根据您的选择,许可方式为

无运行时依赖