Crate base65536[−][src]
Expand description
A binary encoding optimized for UTF-32/UCS-4 encoded text and Twitter.
This is a Rust reimplementation of qntm’s original base65536.
Examples
Decoding:
use base65536::decode; // don't ignore garbage - note that this means that word wrapping doesn't work assert_eq!(vec![1, 2, 3], decode("㘁ᔃ", false)?); assert_eq!("hello world", String::from_utf8(decode("驨ꍬ啯𒁷ꍲᕤ", false)?)?); // ignore garbage assert_eq!(vec![1, 2, 3], decode("㘁asdfghjklᔃ", true)?); assert_eq!("hello world", String::from_utf8(decode("驨ꍬ啯𒁷ꍲᕤ\n", true)?)?);
Encoding:
use base65536::{WrapOptions, encode}; // no word wrapping assert_eq!("㘁ᔃ", encode(&[1, 2, 3], None)); assert_eq!("驨ꍬ啯𒁷ꍲᕤ", encode("hello world", None)); // word wrapping assert_eq!("㘁\nᔃ", encode(&[1, 2, 3], 1)); assert_eq!("驨ꍬ啯\n𒁷ꍲᕤ", encode("hello world", 3)); // word wrapping with a custom line ending assert_eq!("㘁\r\nᔃ", encode(&[1, 2, 3], WrapOptions::WrapAtWith(1, "\r\n"))); assert_eq!("驨ꍬ啯\r\n𒁷ꍲᕤ", encode("hello world", WrapOptions::WrapAtWith(3, "\r\n")));
Enums
Error | Represents an error while decoding. |
WrapOptions | Line Wrapping Options. |
Functions
decode | Decode from a reference to a base65536-encoded string as octets. |
decode_buf | Decode from a reference to a base65536-encoded string as octets. Writes into the supplied output buffer, growing it if needed. |
decode_slice | Decode from a reference to a base65536-encoded string as octets. Writes into the supplied slice, returning how many bytes were written. |
encode | Encode arbitrary octets as base65536. |
encode_buf | Encode arbitrary octets as base65536. Writes into the supplied output buffer, growing it if needed. |
Type Definitions
DecodeResult | A specialized |