Guest User

Untitled

a guest
Aug 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. Ruby string representation
  2. "foo \303\255 bar".gsub(/(\d{3})+/) do |match|
  3. match[1..-1].split("\").map{ |octet| octet.to_i(8) }.pack("c*")
  4. end.force_encoding("UTF-8")
  5.  
  6. "foo \303\255 bar".gsub(/(\d{3})+/) { |m| eval('"' + m + '"') }
  7.  
  8. # encoding: utf-8
  9.  
  10. Encoding.default_external = Encoding::UTF_8
  11. Encoding.default_internal = Encoding::UTF_8
Add Comment
Please, Sign In to add comment