From: Thien-Thi Nguyen Date: Sun, 30 Jul 2006 20:21:14 +0000 (+0000) Subject: (url-hexify-string): Rewrite. X-Git-Tag: emacs-pretest-22.0.90~1179 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ecfbb4888a487435190bd3abc1835a5be7ba484d;p=emacs.git (url-hexify-string): Rewrite. --- diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index 901fac01208..e29b4b6b67e 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog @@ -1,3 +1,8 @@ +2006-07-30 Thien-Thi Nguyen + + * url-util.el (url-hexify-string): Rewrite. + Suggested by David Smith . + 2006-07-12 Michael Olson * url-irc.el (url-irc-erc): Call erc-handle-irc-url. diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el index f33a58950fc..4293b0e301f 100644 --- a/lisp/url/url-util.el +++ b/lisp/url/url-util.el @@ -352,17 +352,18 @@ forbidden in URL encoding." This is taken from RFC 2396.") ;;;###autoload -(defun url-hexify-string (str) - "Escape characters in a string." - (mapconcat - (lambda (char) - ;; Fixme: use a char table instead. - (if (not (memq char url-unreserved-chars)) - (if (> char 255) - (error "Hexifying multibyte character %s" str) - (format "%%%02X" char)) - (char-to-string char))) - str "")) +(defun url-hexify-string (string) + "Return a new string that is STRING URI-encoded. +First, STRING is converted to utf-8, if necessary. Then, for each +character in the utf-8 string, those found in `url-unreserved-chars' +are left as-is, all others are represented as a three-character +string: \"%\" followed by two lowercase hex digits." + (mapconcat (lambda (char) + (if (memq char url-unreserved-chars) + (char-to-string char) + (format "%%%02x" char))) + (encode-coding-string string 'utf-8 t) + "")) ;;;###autoload (defun url-file-extension (fname &optional x)