diff options
| author | Thien-Thi Nguyen | 2006-07-30 20:21:14 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2006-07-30 20:21:14 +0000 |
| commit | ecfbb4888a487435190bd3abc1835a5be7ba484d (patch) | |
| tree | 68f98f2785a82c7d1823c4420c9a5ae4dfec6496 | |
| parent | 0f42ea765f6efc819b38e28343ed35f81022d37b (diff) | |
| download | emacs-ecfbb4888a487435190bd3abc1835a5be7ba484d.tar.gz emacs-ecfbb4888a487435190bd3abc1835a5be7ba484d.zip | |
(url-hexify-string): Rewrite.
| -rw-r--r-- | lisp/url/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/url/url-util.el | 23 |
2 files changed, 17 insertions, 11 deletions
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 @@ | |||
| 1 | 2006-07-30 Thien-Thi Nguyen <ttn@gnu.org> | ||
| 2 | |||
| 3 | * url-util.el (url-hexify-string): Rewrite. | ||
| 4 | Suggested by David Smith <davidsmith@acm.org>. | ||
| 5 | |||
| 1 | 2006-07-12 Michael Olson <mwolson@gnu.org> | 6 | 2006-07-12 Michael Olson <mwolson@gnu.org> |
| 2 | 7 | ||
| 3 | * url-irc.el (url-irc-erc): Call erc-handle-irc-url. | 8 | * 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." | |||
| 352 | This is taken from RFC 2396.") | 352 | This is taken from RFC 2396.") |
| 353 | 353 | ||
| 354 | ;;;###autoload | 354 | ;;;###autoload |
| 355 | (defun url-hexify-string (str) | 355 | (defun url-hexify-string (string) |
| 356 | "Escape characters in a string." | 356 | "Return a new string that is STRING URI-encoded. |
| 357 | (mapconcat | 357 | First, STRING is converted to utf-8, if necessary. Then, for each |
| 358 | (lambda (char) | 358 | character in the utf-8 string, those found in `url-unreserved-chars' |
| 359 | ;; Fixme: use a char table instead. | 359 | are left as-is, all others are represented as a three-character |
| 360 | (if (not (memq char url-unreserved-chars)) | 360 | string: \"%\" followed by two lowercase hex digits." |
| 361 | (if (> char 255) | 361 | (mapconcat (lambda (char) |
| 362 | (error "Hexifying multibyte character %s" str) | 362 | (if (memq char url-unreserved-chars) |
| 363 | (format "%%%02X" char)) | 363 | (char-to-string char) |
| 364 | (char-to-string char))) | 364 | (format "%%%02x" char))) |
| 365 | str "")) | 365 | (encode-coding-string string 'utf-8 t) |
| 366 | "")) | ||
| 366 | 367 | ||
| 367 | ;;;###autoload | 368 | ;;;###autoload |
| 368 | (defun url-file-extension (fname &optional x) | 369 | (defun url-file-extension (fname &optional x) |