6 releases (breaking)

0.5.0 Nov 18, 2020
0.4.1 Jul 2, 2020
0.3.0 Jul 2, 2020
0.2.0 Jan 1, 2019
0.1.0 Dec 31, 2018

#1062 in Text processing

Download history 29/week @ 2024-06-15 31/week @ 2024-06-22 7/week @ 2024-06-29 6/week @ 2024-07-06 27/week @ 2024-07-13 22/week @ 2024-07-20 50/week @ 2024-07-27 27/week @ 2024-08-03 22/week @ 2024-08-10 15/week @ 2024-08-17 12/week @ 2024-08-24 17/week @ 2024-08-31 12/week @ 2024-09-07 11/week @ 2024-09-14 44/week @ 2024-09-21 18/week @ 2024-09-28

87 downloads per month
Used in 7 crates (4 directly)

MIT license

23KB
532 lines

MUTF-8

Usage

fn main() {
    let output: Cow<u8> = mutf8::utf8_to_mutf8("Hello, \0World");

    // `output` contains no NUL bytes.
}

There's also a MString and mstr struct.
These are the counterparts to String and str within the standard library.

fn main() {
    let data = mstr::from_utf8(b"\0");
	assert_eq!(data.len(), 2);
}

About

This crate allows converting UTF-8 to and from MUTF-8.

Some data formats, such as the JVM classfile, make use of an altered UTF-8 encoding.
This one in particular is the MUTF-8 variant.

It allows a NUL byte to be encoded without using the NUL byte itself.

WIP

The algorithm itself is done, and useable.
It works as well as any other.

The reason I still call this crate WIP is because of the two String structs.
I'm not happy with them.

I do use this crate for a couple of projects, but none of them make use of the structs themselves.

I typically use this crate as just a jump from a [u8] to a Cow<str>.
So, until I work out where I want to go with this crate, it's probably going to stay like this.

Dependencies

~170KB