pub fn fix_double(str: &str, fill: char) -> StringExpand description
Replaces consecutive identical characters by inserting a fill character between them.
For example, “AA” becomes “AQA” if the fill character is ‘Q’. This is often used in classical ciphers to handle double letters.
NOTE: this function works regardless of alignment; that is, it does not check if the double letters are on a 2-character boundary. Therefore, it is useless for
Playfair, or any bi-grammatic ciphers.
e.g. HELLOWORLD -> HE LX LO WO RL DX but also CETOOTEST -> CE TO XO TE ST
§Arguments
str- The input string to process.fill- The character to insert between identical consecutive characters.
§Returns
A new String with the fill character inserted where necessary.