Menu

#229 url-hexify-string does not handle non-Latin characters

mh-e-8.0
open
nobody
None
5
2016-01-18
2006-11-15
Bill Wohler
No

"David Smith" <davidsmith@acm.org> wrote to the emacs-pretest-bug@gnu.org mailing list:

url-hexify-string does not handle non-latin characters. According to http://www.w3.org/International/O-URL-code.html , the string must be converted to hexadecimal UTF-8 and every hexadecimal byte must be prefixed with a % character. Rewritten url-hexify-string is below:

(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 16)
(format "%%0%x" char)
(let ((ins nil))
(mapconcat=20
(lambda (charhex)
(progn (setq ins (not ins))
(if ins (concat "%" (char-to-string charhex))
(char-to-string charhex))))
(format "%x" char) "")))
(char-to-string char)))
(encode-coding-string str 'utf-8) ""))

Important settings:
value of $LC_ALL: ja_JP.utf8
value of $LC_COLLATE: nil
value of $LC_CTYPE: ja_JP.utf8
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: ja_JP
locale-coding-system: utf-8-unix
default-enable-multibyte-characters: t

Check that this function is in Emacs 22, and then update the version in mh-compat.el with it.

Discussion

  • Bill Wohler

    Bill Wohler - 2013-02-23
    • labels: General -->
     
  • Bill Wohler

    Bill Wohler - 2013-02-23
    • Status: open --> unread
     
  • Bill Wohler

    Bill Wohler - 2016-01-18
    • status: unread --> open
     

Log in to post a comment.

MongoDB Logo MongoDB