Function zalgo_codec::zalgo_decode

source ·
pub fn zalgo_decode(encoded: &str) -> Result<String, FromUtf8Error>
Expand description

Takes in a string that was encoded by zalgo_encode and decodes it back into an ASCII string.

Errors

Returns an error if the decoded string is not valid UTF-8. This can happen if the input is a string that was not encoded by zalgo_encode, since the byte manipulations that this function does could result in invalid unicode in that case. Even if no error is returned in such a case the results are not meaningful. If you want to be able to decode without this check, consider using a ZalgoString.

Examples

Basic usage:

assert_eq!(zalgo_decode("É̺͇͌͏")?, "Zalgo");

Decoding arbitrary strings that were not produced by zalgo_encode will most likely lead to errors:

assert!(zalgo_decode("Zalgo").is_err());

If it doesn’t the results are not meaningful:

assert_eq!(zalgo_decode("awö")?, "c");