[Tex/LaTex] Problem with url link-`~` is replaced by %257E

acrobathyperrefpdftildeurls

I am adding a url in my document using \url{}. The link, however doesn't lead to where it is suppossed to lead. My code is

\documentclass{article}
\usepackage{hyperref}
\begin{document}
        \url{http://www.phy.duke.edu/~rgb/Class/phy319/phy319/node75.html}
\end{document}

The output is

enter image description here

If I click on it it takes me to

http://www.phy.duke.edu/%257Ergb/Class/phy319/phy319/node75.html

Notice that ~ is replaced by %257E.

Any ideas on why is this happening or how could it be fixed?

Best Answer

I have seen/analyzed the problem some time ago. The reason is a buggy PDF viewer (some versions of AR), see giordano's comments.

Package hyperref writes the URL into the PDF fil, e.g. pdfTeX or dvips/ps2pdf:

/URI(http://www.phy.duke.edu/~rgb/Class/phy319/phy319/node75.html)

The more canonical URI would be with percent encoding:

http://www.phy.duke.edu/%7Ergb/Class/phy319/phy319/node75.html

But the bug duplicates this step.

Clumsy workaround: URL shortening services (TinyURL and other) without special characters in the generated URL to replace the URL in the PDF file. Also possible with \href:

\href{<short URL with harmless characters>}{\nolinkurl{<original URL>}}