Hey Emacs-w3m, meet IDNs!

Despite IDNA support is bundled with Emacs since 2003 (C-h f idna-*), Emacs-w3m does not handle international domains. It simply encodes all non-ASCII characters in the given URL, which makes in the context of IDNs non-sense. But advising the function w3m-url-transfer-encode-string—responsible for urlencoding unsafe data—to pre-encode IDNs may help a lot. My solution below has a known limitation, so that after activating encode-idna, w3m-url-transfer-encode-string will refuse invalid URL schemes.

(defadvice w3m-url-transfer-encode-string
  (around encode-idna (url &optional coding))
  (let* ((host (w3m-http-url-host
                (w3m-parse-http-url (w3m-canonicalize-url url))))
         (url (replace-regexp-in-string host (idna-to-ascii host) url)))
    ad-do-it))

(ad-activate 'w3m-url-transfer-encode-string)

From now, you can w3m-goto-url my slides at gábor.20y.hu.