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

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

Re: Parsing of multibyte strings frpom process output


From: Michael Albinus
Subject: Re: Parsing of multibyte strings frpom process output
Date: Tue, 08 May 2018 14:47:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Noam Postavsky <npostavs@gmail.com> writes:

> I think making a unibyte string would fit better.
>
> (let ((res-symlink-target "/home/albinus/tmp/\\xc2\\x9abung"))
>   (setq res-symlink-target (encode-coding-string
>                             res-symlink-target
>                             'us-ascii t))
>   (decode-coding-string
>    (replace-regexp-in-string
>     "\\\\x\\([[:xdigit:]]\\{2\\}\\)"
>     (lambda (x)
>       (unibyte-string
>        (string-to-number (match-string 1 x) 16)))
>     res-symlink-target)
>    'utf-8))
>
> Although, both methods give me "/home/albinus/tmp/\232bung", so I
> might be missing something...

Both methods are doing the same, I believe. But I like your snippet much
better than mine, so I will use it (if you don't object).

Your first part (encoding in us-ascii) doesn't seem to be necessary in
my case, because the gio tool prints all non-ascii characters of the
symbolic link file name in the syntax I've shown.

Thanks, and best regards, Michael.



reply via email to

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