How do I escape a Unicode string with Ruby?

前端 未结 6 899
春和景丽
春和景丽 2020-12-14 22:10

I need to encode/convert a Unicode string to its escaped form, with backslashes. Anybody know how?

6条回答
  •  温柔的废话
    2020-12-14 23:06

    To use a unicode character in Ruby use the "\uXXXX" escape; where XXXX is the UTF-16 codepoint. see http://leejava.wordpress.com/2009/03/11/unicode-escape-in-ruby/

提交回复
热议问题