[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[QUESTION] buffer-substring-no-properties returned string not display Ch
From: |
Christopher M. Miles |
Subject: |
[QUESTION] buffer-substring-no-properties returned string not display Chinese correctly |
Date: |
Fri, 03 Jun 2022 12:38:03 +0800 |
User-agent: |
mu4e 1.6.10; emacs 28.1 |
When I use this code to read a file content which contains Chinese text.
The returned string does not displaying Chinese correctly.
Here is the code snippet:
#+begin_src emacs-lisp
(defun org-link-beautify--preview-text-file (file lines)
"Return first LINES of FILE."
(with-temp-buffer
(condition-case nil
(progn
(insert-file-contents-literally file)
(format "%s\n"
(mapconcat
'concat
;; extract lines of file contents
(cl-loop repeat lines
unless (eobp)
collect (prog1 (buffer-substring-no-properties ;
FIXME: the encoding of Chinese text is wrong.
(line-beginning-position)
(line-end-position))
(forward-line 1)))
"\n")))
(file-error
;; XXX: reference to free variable ‘noerror’.
(funcall (if noerror #'message #'user-error)
"Unable to read file %S"
file)
nil))))
(org-link-beautify--preview-text-file
(expand-file-name "~/Code/Emacs/org-link-beautify/README.org")
5)
#+end_src
Here is the file content:
#+begin_src org :file "README.org"
,* Motivation
美化并预览 Org Mode 的链接。支持一些文件的缩略图,预览,等特性。
Usually Org links only have text, it's not very intuitive to recognize what type
of link it is. Add some color and icon, even image preview will help user read
links.
#+end_src
--
[ stardiviner ]
I try to make every word tell the meaning that I want to express.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
signature.asc
Description: PGP signature
- [QUESTION] buffer-substring-no-properties returned string not display Chinese correctly,
Christopher M. Miles <=