我正在尝试将列表转换\'(110 111 101 204 136 108)为字符串,如"noe\xcc\x88l".
我尝试使用(mapcar (lambda (c) (decode-char \'unicode c)) \'(110 111 101 204 136 108)),但结果是(110 111 101 204 136 108),与输入相同。(另外,我认识到无法从 UTF-8 的单个字节解码 Unicode 字符,因此这绝对是错误的函数。)
几个选项...
(with-temp-buffer
(set-buffer-multibyte nil)
(apply #'insert '(110 111 101 204 136 108))
(decode-coding-region (point-min) (point-max) 'utf-8 t))
Run Code Online (Sandbox Code Playgroud)
或者:
(decode-coding-string
(mapconcat #'byte-to-string '(110 111 101 204 136 108) "")
'utf-8)
Run Code Online (Sandbox Code Playgroud)
或者更直接:
(string-as-multibyte
(apply #'unibyte-string '(110 111 101 204 136 108)))
Run Code Online (Sandbox Code Playgroud)