1

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?

1 Answer 1

1

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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