Mega Code Archive

 
Categories / Ruby / String
 

Forece_encoding to change the encoding

s = "\xa4".force_encoding("utf-8")  # This is not a valid UTF-8 string s.valid_encoding?                   # => false