Mercurial > emacs
comparison lisp/url/url-util.el @ 72196:5b336ff592bb
(url-hexify-string): Rewrite.
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Sun, 30 Jul 2006 20:19:36 +0000 |
parents | e8a3fb527b77 |
children | 23d71f51857b |
comparison
equal
deleted
inserted
replaced
72195:c348014e6508 | 72196:5b336ff592bb |
---|---|
350 ?- ?_ ?. ?! ?~ ?* ?' ?\( ?\)) | 350 ?- ?_ ?. ?! ?~ ?* ?' ?\( ?\)) |
351 "A list of characters that are _NOT_ reserved in the URL spec. | 351 "A list of characters that are _NOT_ reserved in the URL spec. |
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) |
369 "Return the filename extension of FNAME. | 370 "Return the filename extension of FNAME. |
370 If optional variable X is t, | 371 If optional variable X is t, |