[Top][All Lists]

[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."
    (condition-case nil
          (insert-file-contents-literally file)
          (format "%s\n"
                   ;; 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.
                                      (forward-line 1)))
       ;; XXX: reference to free variable ‘noerror’.
       (funcall (if noerror #'message #'user-error)
                        "Unable to read file %S"

 (expand-file-name "~/Code/Emacs/org-link-beautify/")

Here is the file content:

#+begin_src org :file ""
,* 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 

[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

Attachment: signature.asc
Description: PGP signature

reply via email to

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