Skip to content

Instantly share code, notes, and snippets.

@jdzak
Last active July 11, 2018 11:14
Show Gist options
  • Save jdzak/ad38a9efd3444ddd85b8bfb69974a19c to your computer and use it in GitHub Desktop.
Save jdzak/ad38a9efd3444ddd85b8bfb69974a19c to your computer and use it in GitHub Desktop.
Encoding Fun with Kara
>> File.open("/Users/tablexi/Desktop/utf8", "r:UTF-8") { |f| f.each { |b| puts b.each_codepoint.to_a } }
241
10
=> #<File:/Users/tablexi/Desktop/utf8 (closed)>
>> File.open("/Users/tablexi/Desktop/latin1", "r:ISO-8859-1") { |f| f.each { |b| puts b.each_codepoint.to_a } }
241
10
=> #<File:/Users/tablexi/Desktop/latin1 (closed)>
>> File.open("/Users/tablexi/Desktop/latin1", "r:ISO-8859-1") { |f| f.each { |b| puts b.bytes } }
241
10
=> #<File:/Users/tablexi/Desktop/latin1 (closed)>
>> File.open("/Users/tablexi/Desktop/utf8", "r:UTF-8") { |f| f.each { |b| puts b.bytes } }
195
177
10
=> #<File:/Users/tablexi/Desktop/utf8 (closed)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment