How to convert a string that is in UCS2 (2 bytes per character) into a UTF8 string in Ruby?
With Ruby 1.9:
string.encode("utf-8")
If the string encoding is not known, you may need to set it first:
string.force_encoding("utf-16be").encode("utf-8") # Big-endian string.force_encoding("utf-16le").encode("utf-8") # Little-endian