But, when I run this on the server I get binary characters. Why is that?
I need it to be string (like on IRB). What am I missing?
It appears that you’re getting binary data in irb as well. It’s just
that irb is showing the string using its inspect method. String#inspect
will produce a representation of the string that could be used as a
literal, so all of the non-printable characters without any other
representation such as \n, \t, etc. are replaced with \nnn sequences
where nnn is a number representing the binary value of the byte.