How to disable percent-encoding in URLs?

I try to add a unicode URL into the bibliography and LaTeX automatically converts the cyrillyc letters into percent-encoding. I found that hyperref is responsible for this, but I found no way to disable it. It's OK to encode the link itself, but in document I don't need this, the reader wants to see letters instead of character codes. I really don't want to print this https://ru.wikipedia.org/wiki/SLAM_(%D0%BC%D0%B5%D1%82%D0%BE%D0%B4) on papaer, this gives no useful information to reader.

TeX:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[english, russian]{babel}

\usepackage{biblatex}

\begin{document}
Hello \cite{Wiki:SLAM}.
\printbibliography
\end{document}


1.bib:

@InCollection{Wiki:SLAM,
title     = {SLAM (метод)},
booktitle = {Википедия~"--- свободная энциклопедия},
organization = {Wikimedia Foundation, Inc.},
date      = {2016-05-23},
url       = {https://ru.wikipedia.org/wiki/SLAM_(метод)},
urldate   = {2017-02-22},
language  = {russian},
}


Result:

I want to have https://ru.wikipedia.org/wiki/SLAM_(метод) in the URL.

• I still have trouble with this. Are there no solutions appeard after about two years? I even tried to use a usera field for URLs, but \DeclareFieldFormat{url}{\mkbibacro{URL}\addcolon\space\\thefield{usera}} did not work (( – Himura Dec 3 '18 at 8:20

A current biber knows the option --nouri-encode and then you get this

which isn't a sensible output either.

With a unicode engine like lualatex or xelatex and such a document (and again with --nouri-encode)

\documentclass{article}
\usepackage[english, russian]{babel}

\usepackage{biblatex}
\usepackage{fontspec}
\setmainfont{Arial Unicode MS} %something with cyrillic
\setmonofont{Arial Unicode MS} %something with cyrillic
\begin{document}
Hello \cite{Wiki:SLAM}.
\printbibliography
\end{document}


Adding hyperref to the document will give the same output but the link will be wrong:

Edit

As the comment made clear that pdflatex solution is needed some background info: As the following example demonstrates url.sty can't in a realiable way print non-ascii chars. Depending on the surrounding language (and also depending on packages like hyperref) you get all sorts of wrong output.

The only way to get a perfect output is to handcraft it. This means that if you want this from a bib-file you will have to put the print version of the url in some extra field and change the biblatex macros for the url to use them.

\documentclass[parskip=half-]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1, T2A]{fontenc}
\usepackage[english,russian]{babel}
\usepackage{url}

\begin{document}

\minisec{Russian / T2A-encoding}

normal text:
https://ru.wikipedia.org/wiki/SLAM\_(метод)

url: \url{https://ru.wikipedia.org/wiki/SLAM_(метод)} %wrong output

{%correct output, \babelhyphen{empty} for breakpoint, _ has been escaped to \_
\fontencoding{T1}\ttfamily
https://\babelhyphen{empty}ru.\babelhyphen{empty}wikipedia.\babelhyphen{empty}org/%
\babelhyphen{empty}wiki/\babelhyphen{empty}SLAM\_({\fontencoding{T2A}\selectfont метод})
}

\selectlanguage{english}
\minisec{English / T1-encoding}

normal text: % https://ru.wikipedia.org/wiki/SLAM\_(метод) %errors

url: \url{https://ru.wikipedia.org/wiki/SLAM_(метод)} %wrong output

{%correct output, \babelhyphen{empty} for breakpoint, _ has been escaped to \_
\fontencoding{T1}\ttfamily
https://\babelhyphen{empty}ru.\babelhyphen{empty}wikipedia.\babelhyphen{empty}org/%
\babelhyphen{empty}wiki/\babelhyphen{empty}SLAM\_({\fontencoding{T2A}\selectfont метод})
}
\end{document}


• So there's no way to handle this in pure LaTex? – Himura Feb 22 '17 at 13:02
• I should inform that I use fonts from pscyr and they absolutely support Cyrillic. Something strange is going on here and I start to think about a bug in biber – Himura Feb 22 '17 at 15:55
• That's sad... Well, maybe I really should switch to XeLaTeX, now when I think about it, I see that fonts in LaTeX make really much problems. Thanks for help. – Himura Feb 22 '17 at 16:26
• I thought a bit about this problem in the last days. And imho the best would be to put the correct (percent encoded) url in the url field of the bib, and to add a version for printing in some user field (e.g. usera). This version could then be fine tuned. Changing biblatex to use \href{url}{usera} shouldn't be so difficult. And please stop to think that something is broken: percent encoding is the only correct form for an url see e.g. en.wikipedia.org/wiki/Percent-encoding. Your browser does this conversion internally too. – Ulrike Fischer Feb 27 '17 at 9:45
• You seem not to understand the difference between what you see and what your browser really uses. If you have the chrome browser or firefox: Enter your link, then go to the address bar, select the link and paste it in your editor. Beside this it doesn't make sense to add a ticket to biber. It is not biber's fault that with pdflatex url.sty can not reliably print an url with cyrillic chars and that you can't use a real unicode engine. Add a ticket to the tracker of your class that it adapts to unicode. – Ulrike Fischer Feb 27 '17 at 10:01

Using XeLaTeX, there actually is a solution.

\documentclass{article}

\usepackage[english, russian]{babel}
\usepackage{biblatex}
\usepackage{libertine}
\usepackage{hyperref}
\urlstyle{same} % to use a font with Cyrillic characters

\DeclareFieldFormat{url}{%

\begin{document}
Hello \cite{Wiki:SLAM}.
\printbibliography
\end{document}


(The file 1.bib is as above.) The code uses a new feature of biber (starting with version 2.8): it provides the original, unconverted URL data in the field urlraw (and there is no longer an option --nouri-encode, BTW). We redefine the url field formatter to call \href with the data from urlraw as the second argument.

For CJK characters in bibliography entries there is also a simple solution.

First, the file 2.bib.

@online{Gakushyu,
author  = {Wikipedia},
title   = {学習指導要領 [Gakushū-shidō-yōryō]},
langid  = {japanese},
date    = {2017-12-24},
url     = {https://ja.wikipedia.org/wiki/学習指導要領#2020年（平成32年）_-},
urldate = {2018-01-15},
}


And here an input example.

\documentclass{article}

\usepackage[english]{babel}
\usepackage{biblatex}
\usepackage[CJKmath]{xeCJK}
\usepackage{libertine}
\usepackage{hyperref}

\setCJKmainfont{ipam.ttf}

\DeclareFieldFormat{url}{%

\begin{document}
Hello \cite{Gakushyu}.
\printbibliography
\end{document}


\url (and \nolinkurl) handle URLs in math mode, and option CJKmath activates CJK support for math.

A minor disadvantage is that strings of CJK characters can't be broken. In most cases this shouldn't be a problem. However, if you really need that, a more elaborate solution is necessary that avoids \nolinkurl.

\documentclass{article}

\usepackage[english]{babel}
\usepackage{biblatex}
\usepackage{xeCJK}
\usepackage{libertine}
\usepackage{hyperref}

\setCJKmainfont{ipam.ttf}

\begingroup
\XeTeXinterchartokenstate = 1
\newXeTeXintercharclass \urlBreakClass
\endgroup

\DeclareFieldFormat{url}{%
\begingroup
\XeTeXinterchartokenstate = 1
\XeTeXcharclass \/ \urlBreakClass
\XeTeXinterchartoks \urlBreakClass 0 {\allowbreak}%
\XeTeXinterchartoks \urlBreakClass 1 {%
\allowbreak
\csname xeCJK_class_group_begin:\endcsname
\csname xeCJK_select_font:\endcsname
\csname xeCJK_clear_inter_class_toks:nn\endcsname{Default}{CJK}%
\csname xeCJK_clear_Boundary_and_CJK_toks:\endcsname
\CJKsymbol}%
\endgroup}

\begin{document}
Hello \cite{Gakushyu}.
\printbibliography
\end{document}


To allow line breaks after / (but not between the two slashes in //) we use the \XeTeXcharclass feature: We define a new character class for /, then calling \allowbreak if we have a transition from / to a normal character. It is straightforward to add more characters to the new class if desired.

Because we define a separate class for /, xeCJK's mechanism doesn't get applied to the character following it, and we have to insert the corresponding code into our class token list (this is a hack; hopefully, there will be a better solution in the future). The five lines after \allowbreak have been taken from file xeCJK.sty (version 3.5.1), lines 740ff. Since xeCJK is written in LaTeX3, we use \csname to call the macros. Note that the above code covers only the simplest case, namely / followed by an ordinary CJK character (which xeCJK assigns to class 1).

After two years, there's still no solution. All I managed to do is to handcraft the entity like this:

@Misc{Wiki:SLAM,
title        = {SLAM (метод) [Электронный ресурс] // Википедия~--- свободная энциклопедия},
year         = {2016},
howpublished = {URL: http://ru.wikipedia.org/wiki/SLAM\_(метод) (дата обр.~22.02.2017)},
language     = {russian},
}
`