Show
Ignore:
Timestamp:
08/10/06 11:19:54 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/url/url-util.el

    r4037 r4140  
    164164  "Return a 'normalized' version of URL. 
    165165Strips out default port numbers, etc." 
    166   (let (type data grok retval) 
     166  (let (type data retval) 
    167167    (setq data (url-generic-parse-url url) 
    168168          type (url-type data)) 
     
    353353 
    354354;;;###autoload 
    355 (defun url-hexify-string (str) 
    356   "Escape characters in a string." 
    357   (mapconcat 
    358    (lambda (char) 
    359      ;; Fixme: use a char table instead. 
    360      (if (not (memq char url-unreserved-chars)) 
    361          (if (> char 255) 
    362                (error "Hexifying multibyte character %s" str) 
    363            (format "%%%02X" char)) 
    364        (char-to-string char))) 
    365    str "")) 
     355(defun url-hexify-string (string) 
     356  "Return a new string that is STRING URI-encoded. 
     357First, STRING is converted to utf-8, if necessary.  Then, for each 
     358character in the utf-8 string, those found in `url-unreserved-chars' 
     359are left as-is, all others are represented as a three-character 
     360string: \"%\" followed by two lowercase hex digits." 
     361  ;; To go faster and avoid a lot of consing, we could do: 
     362  ;;  
     363  ;; (defconst url-hexify-table 
     364  ;;   (let ((map (make-vector 256 nil))) 
     365  ;;     (dotimes (byte 256) (aset map byte 
     366  ;;                               (if (memq byte url-unreserved-chars) 
     367  ;;                                   (char-to-string byte) 
     368  ;;                                 (format "%%%02x" byte)))) 
     369  ;;     map)) 
     370  ;; 
     371  ;; (mapconcat (curry 'aref url-hexify-table) ...) 
     372  (mapconcat (lambda (byte) 
     373               (if (memq byte url-unreserved-chars) 
     374                   (char-to-string byte) 
     375                 (format "%%%02x" byte))) 
     376             (if (multibyte-string-p string) 
     377                 (encode-coding-string string 'utf-8) 
     378               string) 
     379             "")) 
    366380 
    367381;;;###autoload 
     
    390404  (let* ((fr-width (or width (frame-width))) 
    391405         (str-width (length url)) 
    392          (tail (file-name-nondirectory url)) 
    393406         (fname nil) 
    394407         (modified 0) 
     
    398411             (string-match "?" url)) 
    399412        (setq url (concat (substring url 0 (match-beginning 0)) "?...") 
    400               str-width (length url) 
    401               tail (file-name-nondirectory url))) 
     413              str-width (length url))) 
    402414    (if (< str-width fr-width) 
    403415        nil                             ; Hey, we are done!