Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 6th, 2012  |  syntax: None  |  size: 0.22 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. convert unicode into character with ruby
  2. p "国".unpack("U*").first #this gives the unicode 22269
  3.        
  4. [22269].pack('U*') #=> "国" or "345233275"
  5.        
  6. p "国".codepoints.first #=> 22269
  7. p 22269.chr('UTF-8') #=> "国"