[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Decoding URLs input

From: Jean Louis
Subject: Re: Decoding URLs input
Date: Sat, 3 Jul 2021 22:17:39 +0300
User-agent: Mutt/2.0.7+183 (3d24855) (2021-05-28)

* Yuri Khan <> [2021-07-03 14:12]:
> What you are dealing with is a URL, specifically, its query string
> part. These are described in RFC 3986, and its percent-encoding scheme
> in sections 2.1 and 2.5.
> (url-unhex-string …) will do half the work for you: It will decode
> percent-encoded sequences into bytes. By convention, in URLs,
> characters are UTF-8-encoded before percent-encoding (see RFC 3986 §
> 2.5), so you’ll need to use:
>     (decode-coding-string (url-unhex-string s) 'utf-8)
> to get a fully decoded text string.

That is very correct and I have implemented that now. Until now it
worked without `decode-coding-string' and I totally forgot UTF-8. When
I faced the fact that spaces are replaced with plus `+' I started
diggin more. It is not first time to deal with it, who knows which
time and each time I stumble upon UTF-8 handlings, this time you were
one step ahead of me, I have not stumbled upon it and could not
discover what is missing.

>From docstring of `url-unhex-string' I did not expect it would give
just bytes back, then that should be IMHO described there, I am not
sure really. Maybe it is assumed for programmer to know that. The
docstring is poor, it says like: "Remove %XX embedded spaces, etc in a
URL." -- with "remove" I don't expect converting UTF-8 into bytes.

I guess now it is clear.

I am now solving the issue that spaces are converted to plus sign and
that I have to convert + signs maybe before:
(decode-coding-string (url-unhex-string "Hello+There") 'utf-8)
but maybe not before, maybe I leave it and convert later.

Problem I have encountered is that library subr.el does not provide
feature 'subr -- and I think I did file report but without
acknowledgment and without seeing it being filed under my email. So I

So I cannot use in CGI script the function `string-replace' or as it
asks for that file but I cannot `require' it, as it is not
"provided", so I have to add that line. I would not like really
fiddling on server with main Emacs files.


Take action in Free Software Foundation campaigns:

In support of Richard M. Stallman

reply via email to

[Prev in Thread] Current Thread [Next in Thread]