I want to escape TeX codes on a range of text; this is for a macro providing slightly neater URL formatting. The code I have now is,

```
\newcommand{\serifurl}[2]{\textsf{\href{#1://#2}{#2}}}

```

where the first arg is the protocol (http) and second is rest of the link. While the link is generated correctly for the PDF, the tilde characters are not escaped (they turn into whitespace), making the print version incorrect. I want something like `\verb` without the formatting.