1

I'd like low-level control over exactly what bytes I send and receive from a process spawned from some vimscript. What encoding is used for communications with commands started with :!foo? Can I influence this choice? How are newlines handled?

  • There is the 'termencoding' option. The help page at :h encoding-table also talks a bit about this. – Christian Brabandt Feb 27 '18 at 7:58
  • @ChristianBrabandt Hm. None of the :help text about 'termencoding' or encoding-table mentions anything about communications with subprocesses; why do you think that's the right option? From my tests it also doesn't seem to control the encoding used for communicating with subprocesses; from a new file, :set encoding=latin1 fileencoding=latin1 termencoding=utf-8, and insert a single 0xff byte (e.g. by <Ctrl-v>xff). Then :%!xxd will show that xxd received an 0xff byte, which is not the utf-8 encoding of codepoint 255. – Daniel Wagner Feb 27 '18 at 14:27
  • I am not sure what you mean with subprocesses. Termencoding is what is used to convert the output from running external processes to the internal used encoding. If 'termencoding isn't set, then I think Vim assumes the external programs to execute in 'encoding' BTW: you should never set 'encoding' after startup. – Christian Brabandt Feb 27 '18 at 14:43
  • @ChristianBrabandt You say 'termencoding' is used to convert output from external processes. I haven't tested that, so it may be right, and I'll try later to verify/refute. In the meantime, what encoding is used to send input to external processes? As my proposed experiment above shows, it isn't 'termencoding'. – Daniel Wagner Feb 27 '18 at 14:46
  • It's 'encoding' as said before. That is my understanding from the documentation and what my past experience shows. I have never verified it at the source level, which is the reason I am posting this as comment and not as answer. – Christian Brabandt Feb 27 '18 at 15:10

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.