MCPcopy Index your code
hub / github.com/BurntSushi/utf8-ranges

github.com/BurntSushi/utf8-ranges @1.0.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.4 ↗ · + Follow
31 symbols 53 edges 3 files 10 documented · 32%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

DEPRECATED: This crate has been folded into the regex-syntax and is now deprecated.

utf8-ranges

This crate converts contiguous ranges of Unicode scalar values to UTF-8 byte ranges. This is useful when constructing byte based automata from Unicode. Stated differently, this lets one embed UTF-8 decoding as part of one's automaton.

Linux build status

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/utf8-ranges

Example

This shows how to convert a scalar value range (e.g., the basic multilingual plane) to a sequence of byte based character classes.

extern crate utf8_ranges;

use utf8_ranges::Utf8Sequences;

fn main() {
    for range in Utf8Sequences::new('\u{0}', '\u{FFFF}') {
        println!("{:?}", range);
    }
}

The output:

[0-7F]
[C2-DF][80-BF]
[E0][A0-BF][80-BF]
[E1-EC][80-BF][80-BF]
[ED][80-9F][80-BF]
[EE-EF][80-BF][80-BF]

These ranges can then be used to build an automaton. Namely:

  1. Every arbitrary sequence of bytes matches exactly one of the sequences of ranges or none of them.
  2. Every match sequence of bytes is guaranteed to be valid UTF-8. (Erroneous encodings of surrogate codepoints in UTF-8 cannot match any of the byte ranges above.)

Core symbols most depended-on inside this repo

len
called by 6
src/lib.rs
push
called by 6
src/lib.rs
never_accepts_surrogate_codepoints
called by 6
src/lib.rs
encode_utf8
called by 3
src/char_utf8.rs
as_slice
called by 2
src/lib.rs
is_valid
called by 2
src/lib.rs
matches
called by 1
src/lib.rs
reset
called by 1
src/lib.rs

Shape

Method 15
Function 12
Class 3
Enum 1

Languages

Rust100%

Modules by API surface

src/lib.rs28 symbols
benches/bench.rs2 symbols
src/char_utf8.rs1 symbols

For agents

$ claude mcp add utf8-ranges \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact