This is related to this question
but is specific to DOIs and does not involve unicode characters.
I have to use strange DOIs like this
10.1175/1520-0485(1986)016<1929:CTWOTE>2.0.CO;2
So, I need to able to build a command like
\doi{10.1175/1520-0485(1986)016<1929:CTWOTE>2.0.CO;2}
->
\href%
{http://doi.org/10.1175/1520-0485%281986%29016%3C1929%3ACTWOTE%3E2.0.CO%3B2}%
{doi:10.1175/1520-0485(1986)016<1929:CTWOTE>2.0.CO;2}
That is, I need a valid URL in the first argument to \href based on a DOI which includes invalid characters as URL.
We can assume that there is an external command that escapes invalid characters in a URL:
$ urlencode '10.1175/1520-0485(1986)016<1929:CTWOTE>2.0.CO;2'
10.1175/1520-0485%281986%29016%3C1929%3ACTWOTE%3E2.0.CO%3B2
$
If I knew how to call an external program and catch its standard output, I would be able to build such a LaTeX command.
Or maybe somebody already has a solution.
If urlencode can be used from within LaTeX, it would serve as a solution to the unicode character problem, too.
By the way, a URL with invalid characters still works on Adobe Reader, but it doesn't on Apple's PDF viewer and other PDF viewers that use Webkit (so I was told). I suspect that Apple wouldn't fix it because the URL is invalid after all.