Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Messing with process IO and encodings

View read-utf16.rb
1 2 3 4 5
IO.popen(%w!ruby utf16.rb!, 'rb', external_encoding:'UTF-16BE') do |io|
line = io.read.encode('UTF-8')
p line # => "ABCD0123"
puts line.each_byte.map{|b|'%02x'%b}.join(' ') # => 41 42 43 44 30 31 32 33
end
View read-utf16.rb
1
STDOUT.write 'ABCD0123'.encode('UTF-16BE')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.