pub fn fix_double_aligned(str: &str, fill: char) -> StringExpand description
Replaces consecutive identical characters by inserting a fill character between them, but only when the duplicate pair falls on a 2-character boundary.
This function is specifically designed for bi-grammatic ciphers like Playfair, where doubles must be fixed only if they would form a single digram (2-character block).
Unlike fix_double, this function respects alignment. It processes the string in
2-character chunks and only inserts the fill character when both characters in a
digram are identical.
e.g. HELLOWORLD -> HE LX LO WO RL DX (LL becomes LX, DD becomes DX) CETOOTEST -> CE TO OT ES TX (OO is on boundary, so no change needed as they’re in different digrams)
§Arguments
str- The input string to process.fill- The character to insert between identical characters in the same digram.
§Returns
A new String with the fill character inserted where necessary, respecting 2-character boundaries.