base256u
Just a simple Rust crate to map between bytes and unicode glyphs. Includes
reference printable-ascii-preserved Unicode (papu) encoder and decoder
functions, as well as emoji ones. The papu encoding will preserve all text
that is already only printable ascii characters and all the other bytes map to
single-codepoint non-combining printable glyphs, skipping odd things like NBSP
and SHY.
Creating your own custom encodings is trivial as well.
Using this crate is as simple as use base256u::{Decode, Encode}; and then
calling the base256u() method or base256u_papu() to get the default papu
encoding.
Encoding
use Encode as _;
let encoded: String = .base256u_papu.collect;
assert_eq!;
let encoded: String = b"Pack my box with five dozen liquor jugs."
.into_iter
.copied
.base256u_papu
.collect;
assert_eq!;
Decoding
use Decode as _;
let decoded: = r##"°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~§ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇň¤ŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƝʼn"##.chars.base256u_papu.collect;
let mut matcher: = .map.collect;
matcher.push;
matcher.push;
assert_eq!;
let decoded: = "Pack my box with five dozen liquor jugs."
.chars
.base256u_papu
.map
.collect;
assert_eq!;