20

Background

A while ago it became possible to use the letters æ, ø and å in URLs, and some websites, like the encyclopaedia Store Norske Leksikon, has made use of this.

Recently, a question was posted on a Norwegian forum about creating a hyperlink to such an URL, something that doesn't work, at least not with æ and ø.

An example

\documentclass[a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{hyperref} \begin{document} \url{http://snl.no/øl} \\ \url{http://snl.no/ære} \\ \url{http://snl.no/Ål} \end{document} 

The first two links do not work, they are printed as http://snl.no/\T1\ol and http://snl.no/\T1\aere, but the third one works as it should.

(One can get the correct URL printed by using the href command, but as the hyperlink is still wrong, that isn't really a solution.)

The question

I assume this has something to do with how hyperref handles non-english characters. Is there some way of making hyperref create a correct link with æ or ø in the url?

Update

By using the href command, and compiling with latex and the dvipdfm, the hyperlink is correct (see gerry's answer below). I've been compiling with pdflatex.

4

4 Answers 4

6

Actually I can get the right link with href. It's compiled with latex & dvi2pdf

\documentclass[a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{hyperref} \begin{document} \href{http://snl.no/øl}{http://snl.no/øl}\\ \href{http://snl.no/ære}{http://snl.no/ære} \\ \href{http://snl.no/Ål}{http://snl.no/Ål} \end{document} 

alt text

1
  • 1
    Indeed, it appears that this works. Thanks! I haven't compiled to DVI for a long time, so it didn't even occur to me to try. I'll wait a little, and see if anyone has a solution for using pdflatex. If not, I'll accept your answer. Commented Dec 11, 2010 at 15:20
14

With a small modification the answer given by gerry will even work directly with pdflatex:

\documentclass[a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage[]{hyperref} \begin{document} \href{http://snl.no/%C3%B8l}{http://snl.no/øl} \\ \href{http://snl.no/%C3%A6re}{http://snl.no/ære} \\ \href{http://snl.no/%C3%85l}{http://snl.no/Ål} \end{document} 

You just have to encode the URL, for example using the W3 URL Encoder.

2

I get the same results with pdflatex, latex+dvips+ps2pdf and latex+dvipdfmx. In your place I would ask the author of hyperref. E.g. in comp.text.tex.

1

matth's answer works, but applying Heiko's answer (to another question) it is even possible to do:

\documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{hyperref} \begin{document} \href{\detokenize{http://snl.no/øl}}{http://snl.no/øl} \\ \href{\detokenize{http://snl.no/ære}}{http://snl.no/ære} \\ \href{\detokenize{http://snl.no/Ål}}{http://snl.no/Ål} \end{document} 

Saves the need to look up the code for ø, æ, and Å.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.