emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/url/url-util.el,v


From: Thien-Thi Nguyen
Subject: [Emacs-diffs] Changes to emacs/lisp/url/url-util.el,v
Date: Sun, 30 Jul 2006 20:19:37 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Thien-Thi Nguyen <ttn>  06/07/30 20:19:36

Index: url-util.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/url/url-util.el,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- url-util.el 5 Feb 2006 23:15:07 -0000       1.12
+++ url-util.el 30 Jul 2006 20:19:36 -0000      1.13
@@ -352,17 +352,18 @@
 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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]