#utf-8 #string #char #unicode #no-alloc

no-std utf8char

A crate that supplies a utf8 encoded char

2 unstable releases

new 0.2.0 Apr 15, 2025
0.1.0 Oct 26, 2024

#1015 in Data structures

Download history 59/week @ 2025-04-09

59 downloads per month

MPL-2.0 license

53KB
945 lines

A UTF-8 encoded [prim@char].

This alternate representation of a char allows for certain benefits:

  • Deref to &str
  • Hash/Eq/Ord like &str
  • Smaller than &'static str for single codepoint cases (full const support included)
  • Some char methods are implementable without the performance loss of &str -> char -> &str (for instance in a str::chars() loop)

To get started, create a Utf8Char.


utf8char

A char encoded as UTF-8, this has multiple advantages over the char primitive and a one codepoint &str.

Encoding and decoding char<->utf8 is expensive, yet common in cases where the advantages of the char data representation may not matter (see: str::chars() -> transform -> collect::<String>()).

No runtime deps