GNU bug report logs - #22912
url-util: add url-hexify-region, url-unhex-region

Previous Next

Package: emacs;

Reported by: Ivan Shmakov <ivan <at> siamics.net>

Date: Fri, 4 Mar 2016 20:41:01 UTC

Severity: wishlist

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ivan Shmakov <ivan <at> siamics.net>
To: submit <at> debbugs.gnu.org
Subject: url-util: add url-hexify-region, url-unhex-region 
Date: Fri, 04 Mar 2016 20:40:31 +0000
[Message part 1 (text/plain, inline)]
Package:  emacs
Severity: wishlist

	Just like there’s, say, encode-coding-region, interactive
	url-unhex-region and its inverse come handy at times.  Say, one
	may stumble upon a URI like [1], which is hardly legible without
	applying url-unhex-region first.

	Please thus consider adding functions like those MIMEd to
	url-util.el.

[1] https://ru.wikipedia.org/wiki/%D0%A4%D0%BE%D0%BD%D0%B4_%D1%81%D0%B2%D0%BE%D0%B1%D0%BE%D0%B4%D0%BD%D0%BE%D0%B3%D0%BE_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%BD%D0%BE%D0%B3%D0%BE_%D0%BE%D0%B1%D0%B5%D1%81%D0%BF%D0%B5%D1%87%D0%B5%D0%BD%D0%B8%D1%8F

-- 
FSF associate member #7257  http://am-1.org/~ivan/      … 3013 B6A0 230E 334A
[Message part 2 (text/emacs-lisp, inline)]
(defun url-hexify-region (from to &optional coding)
  "URI-encode the current region.
If the region contains multibyte characters, they are first converted to
UTF-8, or to CODING-SYSTEM if non-nil."
  (interactive "r")
  (insert (prog1
              (url-hexify-string
               (encode-coding-string
                (buffer-substring from to)
                (or coding 'utf-8)))
            (delete-region from to))))

(defun url-unhex-region (from to &optional coding)
  "URI-decode the current region.
If CODING is non-nil, use it as the coding system to decode from.
Otherwise, use UTF-8."
  (interactive "r")
  (insert (prog1
              (decode-coding-string
               (url-unhex-string
                (buffer-substring from to))
               (or coding 'utf-8))
            (delete-region from to))))

This bug report was last modified 7 years and 33 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.