I know there's got to be a built-in function to decode a URL-encoded string (query string) in Emacs Lisp, but for the life of me I can't find it today, either in my lisp/ folder or with google.
Anybody remember what it's called?
I know there's got to be a built-in function to decode a URL-encoded string (query string) in Emacs Lisp, but for the life of me I can't find it today, either in my lisp/ folder or with google.
Anybody remember what it's called?
I think you're making it a little too hard: split-string
will probably do most of what you want. For fancier stuff, have a look at the functions in url-expand.el
; unfortunately, many of them don't have doc-strings, so you may have to read code.
url-generic-parse-url
looks like a potential winner.
org-link-unescape
does the job for very simple cases ... w3m-url-decode-string
is better, but it isn't built in and the version I have locally isn't working with Emacs 23.
Emacs is shipped with an URL library, that provides a bunch of URL parsing functions—as huaiyuan and Charlie Martin already pointed out. Here is a small example that'd give you an idea how to use it:
(let ((url "http://www.google.hu/search?q=elisp+decode+url&btnG=Google+keres%E9s&meta="))
;; Return list of arguments and values
(url-parse-query-string
;; Decode hexas
(url-unhex-string
;; Retrieve argument list
(url-filename
;; Parse URL, return a struct
(url-generic-parse-url url)))))
=> (("meta" "") ("btnG" "Google+keresés") ("/search?q" "elisp+decode+url"))
I think is better to rely on it than org-mode
as it is its main purpose to parse URL.