-
-
Save dminuoso/3ba87266e2df0729ca575df7132d6d10 to your computer and use it in GitHub Desktop.
This file contains 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
pprDomain :: Domain -> TL.Text | |
pprDomain (Domain l) = TB.toLazyText build | |
where | |
build :: TB.Builder | |
build = foldl' (\buf x -> buf <> pprLabel x <> ".") mempty l | |
pprLabel :: DomainLabel -> TB.Builder | |
pprLabel (DomainLabel d) = BS.foldl' (\buf x -> buf <> go x) mempty d | |
go :: Word8 -> TB.Builder | |
go c | c > 0x20 | |
&& c <= 0x7E = TB.singleton (w2c c) | |
| otherwise | |
= "\\x" <> TB.fromString (showHex c "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment