From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: William Xu Newsgroups: gmane.emacs.devel Subject: webjump-url-encode and non-ascii characters Date: Wed, 04 Jul 2007 18:34:51 +0800 Organization: the Church of Emacs Message-ID: <876450a244.fsf@www.williamxu.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1183546223 15993 80.91.229.12 (4 Jul 2007 10:50:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 4 Jul 2007 10:50:23 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 04 12:50:20 2007 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1I62R8-00074c-Ed for ged-emacs-devel@m.gmane.org; Wed, 04 Jul 2007 12:50:18 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I62R7-0001yM-2I for ged-emacs-devel@m.gmane.org; Wed, 04 Jul 2007 06:50:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I62Qn-0001eB-1D for emacs-devel@gnu.org; Wed, 04 Jul 2007 06:49:57 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I62Ql-0001c9-6I for emacs-devel@gnu.org; Wed, 04 Jul 2007 06:49:56 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I62Ql-0001by-0r for emacs-devel@gnu.org; Wed, 04 Jul 2007 06:49:55 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1I62CV-0006mA-Sx for emacs-devel@gnu.org; Wed, 04 Jul 2007 06:35:12 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1I62CT-0005xt-VS for emacs-devel@gnu.org; Wed, 04 Jul 2007 12:35:09 +0200 Original-Received: from 203.86.61.139 ([203.86.61.139]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 04 Jul 2007 12:35:09 +0200 Original-Received: from william.xwl by 203.86.61.139 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 04 Jul 2007 12:35:09 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 36 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 203.86.61.139 User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:z4nx6Ga9x54GMcF1tak3V8MpvnE= X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:74292 Archived-At: webjump-url-encode fails to encode non-ascii characters correctly. Here's a patch: --- webjump.el 2007-06-03 14:54:53.000000000 +0800 +++ webjump.el.new 2007-07-04 18:29:41.000000000 +0800 @@ -451,14 +451,13 @@ (defun webjump-url-encode (str) (mapconcat '(lambda (c) - (cond ((= c 32) "+") - ((or (and (>= c ?a) (<= c ?z)) - (and (>= c ?A) (<= c ?Z)) - (and (>= c ?0) (<= c ?9))) - (char-to-string c)) - (t (upcase (format "%%%02x" c))))) - str - "")) + (let ((s (char-to-string c))) + (cond ((string= s " ") "+") + ((string-match "[a-zA-Z_.-/]" s) s) + (t (upcase (format "%%%02x" c)))))) + (string-to-list + (encode-coding-string str buffer-file-coding-system)) + "")) (defun webjump-url-fix (url) (if (webjump-null-or-blank-string-p url) -- William 《出塞》 作者:王之涣 黄河远上白云间,一片孤城万仞山。 羌笛何须怨杨柳,春风不度玉门关。