0

See my minimal example:

var { exec } = require('child_process'); 
var out; 
exec('echo oø', options={encoding: 'buffer'} callback=(err, stdout, stderr) => { out = stdout});

No matter the encoding configuration of exec options and out.toString(encoding=''), oo is passed. Evidently when using 'buffer' encoding in exec, i get:

out:
    <Buffer 6f 6f 0d 0a>
out.toString(): 
    ‘oo\r\n’

Any ideas how to get exec to return "oø" when calling "echo oø"?

Mathias Andersen
  • 478
  • 1
  • 4
  • 9
  • first, your code is not really a valid JS piece of code. second, this code seems to work fine for me. could you clarify what's wrong? and provide actual runnable code – enapupe Mar 23 '21 at 16:15
  • "Your code is not valid JS." ... "Code work fine for me." ... Provide actual runnable code. - What are you saying here? – Mathias Andersen Mar 25 '21 at 20:58
  • the piece of code you shared is a mix of valid JS code with documentation, it's not exactly something you can copy paste and run. Adapting it to atual code, it works as it is supposed. – enapupe Mar 25 '21 at 21:17

0 Answers0