Crates.io | zwnbsp |
lib.rs | zwnbsp |
version | 0.0.1 |
source | src |
created_at | 2020-09-15 02:58:43.572574 |
updated_at | 2020-09-15 20:37:31.477151 |
description | Zero width no-breaking space character utilities for Unicode and HTML |
homepage | |
repository | https://github.com/EstebanBorai/zwnbsp |
max_upload_size | |
id | 288804 |
size | 13,336 |
zwnbsp = "0.0.1"
use zwnbsp::ZeroWidth;
fn main() {
let zero_width = ZeroWidth::new("Hi!").unwrap().to_html();
println!("{}", zero_width);
// ‌​‌​​‌​​​‌‍‌​‌‌​‌​​‌‌‍‌​‌​​​​‌‌‍
}
use zwnbsp::ZeroWidth;
fn main() {
let zero_width = ZeroWidth::new("Hi!").unwrap().to_unicode();
println!("{}", zero_width);
//
}
For every conversion a binary representation of the ASCII text provided is done. This reduces the characters required to represent this data to 3 characters.
One character will represent the 0
value from the binary representations, the second
will represent the 1
value from the binary representation and finally the third
represents spaces to mark off the starting and the end of each binary set.
When performing a conversion from ASCII text to ZWNBSP, the ASCII text is first converted into its binary representation.
Given the text Hi!
the result from encoding into binary would be
01001000 01101001 00100001
.
Then, each value of the binary representation is replaced with its corresponding zero width character.
The process to convert ZWNBSP representations back to human readable ASCII is the "reverse" of
converting from ASCII to ZWNBSP. The binary representation with replaced characters is then
converted back to its binary representation in 1
, 0
and
, and then from binary
representation to text.
When converting some text back to ASCII you must have in mind that the corresponding values may not be the same as used by this crate.
The following flowchart explains the conversion from ASCII to ZWNBSP and from ZWNBSP back to ASCII.
The example Creating an Unicode representation on ZWNBSP characters for "Hi!" contains the value in the comment that appears to be empty.
You can copy the complete snippet, go to diffchecker.com and paste it to find the hidden characters.
To release a new version you must tag with git and push to the main
branch.
git tag -a v0.1.0 -m "First Release"
git push origin main --follow-tags
Every contribution to this project is welcome! Feel free to open a pull request or an issue.
Licensed under MIT License.