I want to run shell command with system function and the command output has some Chinese chars.

echo system('svn status')

But I got incorrect encoding output like this:

svn:  ?\232?\173?\166?\229?\145?\138: W155007: ?\226?\128?\156/Users/mfw?\226?\128?\157?\228?\184?\141?\230?\152?\175?\229?\183?\165?\228?\189?\156?\229?\137?\175?\230?\156?\172

And the correct output is:

svn:  警告: W155007: “/Users/mfw”不是工作副本

So How can I get Chinese chars output correctly?

Thank you!

  • Only macvim has this problem – Fenghua Shu Jun 29 '16 at 10:14
  • Can you try this command :version and put the output here? – SibiCoder Jun 29 '16 at 10:29
  • 1
    We need to check the encoding of shell and vim. In vim, give :set encoding, :set fileencoding, :set termencoding and paste the output here. If all three are utf-8 or a CJK supported encoding, problem is not with vim. For shell: give svn status in shell and check whether you are getting the output as expected. If not, shell has a problem with encoding support. – SibiCoder Jun 30 '16 at 6:09
  • 2
    Thank you @SibiCoder for your response. Yesterday I uninstall macports on my mac, and my svn message became English. I cannot get the incorrect Chinese message now. set encoding: utf-8 set fileencoding: ''(new tab and not file open) set termencoding: utf-8 And svn status in shell is correct. – Fenghua Shu Jul 1 '16 at 2:58
  • 1
    So, you found the answer? Post it here :) – SibiCoder Jul 1 '16 at 5:33

Your Answer

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

Browse other questions tagged or ask your own question.