Skip to content

Instantly share code, notes, and snippets.

@jcoyne
Created November 9, 2012 13:51
Show Gist options
  • Save jcoyne/4045742 to your computer and use it in GitHub Desktop.
Save jcoyne/4045742 to your computer and use it in GitHub Desktop.
Setting default internal_encoding causes Encoding::UndefinedConversionError when writing to popen2
require 'open3'
Encoding.default_internal = Encoding::UTF_8 # works fine if this line is removed
file = File.open('sample.mp3', 'rb')
stdin, stdout, wait_thr = Open3.popen2('mpg321 - -w -|oggenc -')
stdin.write file.read
stdin.close
@jcoyne
Copy link
Author

jcoyne commented Nov 9, 2012

test_popen.rb:5:in write': "\x89" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) from test_popen.rb:7:in

'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment