Reputation: 20746
I have a string received via the gets.chomp
of the TcpSocket
class. How can I determine the encoding of this string? Then I need to convert it to the Windows console encoding so I can print it. Is there any built-in way or third-party library to do it in Ruby?
Thanks in advance.
Upvotes: 12
Views: 8496
Reputation: 118261
Use this method #encoding
- Returns the Encoding object that represents the encoding of obj.
Take look at the class Encoding
to get the ideas, about how to convert to required encodings.
Upvotes: 15