1
2
3
4
5
6
7
8
9
require 'systemu'

status, stdout, stderr = systemu 'tree'

p stdout
puts stdout
p stdout.encoding
puts stdout.force_encoding 'UTF-8'

It’s interesting that puts prints the result correctly.

1
2
3
4
5
6
7
8
".\n\xE2\x94\x9C\xE2\x94\x80\xE2\x94\x80 hello.rb\n\xE2\x94\x94\xE2\x94\x80\xE2\x94\x80 test.rb\n\n0 directories, 2 files\n"
.
├── hello.rb
└── test.rb

0 directories, 2 files
#<Encoding:ASCII-8BIT>
".\n├── hello.rb\n└── test.rb\n\n0 directories, 2 files\n"