help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: function to decode url percent encoding


From: Xah Lee
Subject: Re: function to decode url percent encoding
Date: Wed, 08 Dec 2010 15:09:47 -0000
User-agent: G2/1.0

On May 19, 7:55 am, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> >>> So, i guess i could parse the url then interpret the %x string as
> >>> utf-8 hex bytes then turn them back to unicode chars. Any idea if
> >>> there's built in function that helps this?
> >> There should be one somewhere in the URL package, although I don't know
> >> if it does work right.  If you find it and discover it doesn't work right,
> >> please report it as a bug.
> > It's `url-unhex-string', but it does not work, I guess.
> > (url-unhex-string (url-hexify-string "ä"))
>
> Indeed, we have some problems here:
> 1- a bug in the implementation makes it unwittingly decode the bytes as
>    latin-1.
> 2- the function actually does not decode the result.
>
> Point 1 will be fixed in Emacs-23.3.
> In the meantime you can revert the accidentalencoding:
>
>   (encode-coding-string (url-unhex-string (url-hexify-string "ä")) 'latin-1)
>
> As for point 2 you can do that manually after the call:
>
>   (decode-coding-string (url-unhex-string (url-hexify-string "ä")) 'utf-8)
>
> or if you need to work around point 1 as well (but note that if point
> 1 is fixed, then the below won't work right):
>
>   (decode-coding-string (encode-coding-string
>                          (url-unhex-string (url-hexify-string "ä"))
>                          'latin-1)
>                         'utf-8)
>
> As for whether point 2 should be fixed or not, I'm not completely sure
> yet (I'd tend to say yes, tho).
>
>         Stefan

Thanks all for the answers.

José A Romero L has filed a bug report. #6252

http://groups.google.com/group/gnu.emacs.bug/browse_frm/thread/908f7f39589a9014#
http://groups.google.com/group/gnu.emacs.bug/browse_frm/thread/e997a39309022a3d#

(i cant find the bug in the official site
http://emacsbugs.donarmstrong.com/cgi-bin/pkgreport.cgi?package=emacs
)

there's some temp solutions from Jose's post and Stefan Monnier's
post.

  Xah
∑ http://xahlee.org/

reply via email to

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