emacs-devel
[Top][All Lists]
Advanced

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

Re: fixing url-unhex-string for unicode/multi-byte charsets


From: Stefan Monnier
Subject: Re: fixing url-unhex-string for unicode/multi-byte charsets
Date: Fri, 06 Nov 2020 09:59:02 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>  (dolist (str '("hello%20world"
>                 "%d7%a9%d7%9c%d7%95%d7%9d%20%d7%a2%d7%95%d7%9c%d7%9d"))
>    (insert (decode-coding-string (url-unhex-string str)
>                                  (or file-name-coding-system
>                                      default-file-name-coding-system))
>            "\n"))
>
> The result of evaluating this is two lines inserted into the current
> buffer:
>
>   hello world
>   שלום עולם
>
> If this doesn't work for you, or if you tried something slightly
> different, I'd like to hear the details, perhaps there's some
> subtlety I'm missing.

My guess is that his `file-name-coding-system` is set to something
different from utf-8.
[ BTW, I wouldn't be surprised to hear that the Freedesktop spec
  documents that the file names in the Trash should use utf-8, in which
  case the code should hard-code utf-8 rather than use
  `file-name-coding-system` ;-)  ]

> As a rule of thumb, any Lisp code that needs to do something with a
> string and does that by inserting it into a temporary buffer and
> working on that instead, should raise the "missing primitive" alarm.

Tho only for reasonably trivial amounts of "working on that" ;-)


        Stefan




reply via email to

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