Created
December 17, 2013 16:31
-
-
Save masapico/8007846 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Display bytes in String | |
| puts "- utf-8 ------------------------------" | |
| 'あ'.bytes { |b| puts "#{b.to_s(16)} => #{sprintf("%#010b", b)}" } | |
| puts "- sjis ------------------------------" | |
| 'あ'.encode("Windows-31J").bytes { |b| puts "#{b.to_s(16)} => #{sprintf("%#010b", b)}" } | |
| puts "- utf-16le ---------------------------" | |
| 'あ'.encode("utf-16le").bytes { |b| puts "#{b.to_s(16)} => #{sprintf("%#010b", b)}" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment