#codec #decoding #text #character #encoding #input #zero-width

bin+lib zw

Utility for encoding and decoding text using zero-width characters

2 unstable releases

0.2.0 Aug 13, 2022
0.1.0 Jul 17, 2021

#959 in Text processing

MIT license

7KB
131 lines

ZW

Utility for encoding and decoding text using zero-width characters.

How it works

Subject text is first converted to its binary representation (e.g. "foo" -> "011001100110111101101111"), then each digit is replaced with a zero-width character (specifically: U+200B and U+200C). Decoding is simply the inverse of the same flow of operations.

Usage

As a module:

use zw;
// ...
let encoded = zw::encode("Hello");
let decoded = zw::decode(&encoded);

As a CLI tool:

zw [-e|--encode] [-d|--decode] [input]

If both -e and -d flags are omitted then conversion direction is guessed based on the first interpreted character.

Reads from stdin if an input string isn't provided in its arguments.

# Shell-ish
zw "Hello" > encoded.txt
cat encoded.txt | zw > decoded.txt

# MacOS clipboard encoding
pbpaste | zw | pbcopy

lib.rs:

ZW

Utility for encoding and decoding text using zero-width characters.

How it works

Subject text is first converted to its binary representation (e.g. "foo" -> "011001100110111101101111"), then each digit is replaced with a zero-width character (specifically: U+200B and U+200C). Decoding is simply the inverse of the same flow of operations.

Example usage

use zw;
let encoded = zw::encode("Hello");
let decoded = zw::decode(&encoded);
assert_ne!("Hello", &encoded);
assert_eq!("Hello", &decoded);

Dependencies

~2.5MB
~49K SLoC