Forece_encoding to change the encoding : force_encoding « String « Ruby
- Ruby
- String
- force_encoding
Forece_encoding to change the encoding
s = "\xa4".force_encoding("utf-8") # This is not a valid UTF-8 string
s.valid_encoding? # => false
Related examples in the same category