In ruby-on-rails, how to convert the '\ X93' format as a string format to its original form?
s = "你好"
s.encoding # => #<Encoding:UTF-8>
yaml = s.to_yaml # => "--- \"\\xE4\\xBD\\xA0\\xE5\\xA5\\xBD\"\n"
yaml.encoding # => #<Encoding:ASCII-8BIT>
yaml.force_encoding 'utf-8' # => "--- \"\\xE4\\xBD\\xA0\\xE5\\xA5\\xBD\"\n"
Then, how to make "to_yaml" generate the original look: "你好", I do not mean something like "\ XE4"
Or, anyway, to change the result of "to_yaml" to do this?
Thank!
+3