[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Parsing of multibyte strings frpom process output
From: |
Noam Postavsky |
Subject: |
Re: Parsing of multibyte strings frpom process output |
Date: |
Tue, 8 May 2018 08:21:33 -0400 |
On 8 May 2018 at 08:01, Michael Albinus <michael.albinus@gmx.de> wrote:
> --8<---------------cut here---------------start------------->8---
> (setq res-symlink-target
> ;; Parse multibyte codings.
> (decode-coding-string
> (replace-regexp-in-string
> "\\\\x\\([[:xdigit:]]\\{2\\}\\)"
> (lambda (x)
> (string
> (string-to-number (concat "3FFF" (match-string 1 x)) 16)))
> res-symlink-target)
> 'utf-8))
> --8<---------------cut here---------------end--------------->8---
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...