Last active
August 29, 2015 14:27
-
-
Save locatw/ece1ded34e21af3829b6 to your computer and use it in GitHub Desktop.
Replace "&-" to "&" in byte list in F#. This is used for IMAP-UTF7 decoding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let replaceAmpersandHyphenToAmpersand (input : byte list) = | |
| let replacedTail = | |
| input | |
| |> List.windowed 2 | |
| |> List.choose (fun chunk -> match chunk with | |
| // 0x26 : '&', 0x2d : '-' | |
| | [a; b] when a = (byte)0x26 && b = (byte)0x2d -> None | |
| | [_; b] -> Some(b) | |
| | _ -> failwith "invalid chunk") | |
| input.Head :: replacedTail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment