0

I'm using macOS. I tried using the following command to paste from clipboard in Emacs(started with emacs -Q)

(call-process "/usr/bin/pbpaste" nil t nil)

It works fine for English characters, but not for Chinese characters. For example, if I copy the following Chinese characters in web browser

中文测试

Then run the call-process command above in Emacs, the result would be

????

My system encoding is UTF-8 and I checked Emacs' encoding system was UTF-8 too(By checking the value of buffer-file-coding-system in Emacs, which was 'utf-8).

How to sovle the problem?

0

Finally, I found the answer, just add the following line to your Emacs config file:

(setenv "LANG" "en_US.UTF-8")

The reason is that pbpaste uses the encoding set by the environment variable LANG, by default Emacs don't set this variable, so you need to set it manually. Check this stackoverflow answer for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.