all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#22912: url-util: add url-hexify-region, url-unhex-region
@ 2016-03-04 20:40 Ivan Shmakov
  2018-04-15 19:52 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Ivan Shmakov @ 2016-03-04 20:40 UTC (permalink / raw)
  To: 22912

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/emacs-lisp, Size: 824 bytes --]

(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))))

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-15 19:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-04 20:40 bug#22912: url-util: add url-hexify-region, url-unhex-region Ivan Shmakov
2018-04-15 19:52 ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.