Anonymous user
Read a file character by character/UTF8: Difference between revisions
Read a file character by character/UTF8 (view source)
Revision as of 21:22, 10 May 2020
, 4 years ago→{{header|Crystal}}
No edit summary |
|||
Line 85:
{{trans|Ruby}}
The encoding is UTF-8 by default, but it can be explicitly specified.
<lang ruby>File.open("input.txt", encoding: "UTF-8") do |file|▼
file.each_char { |c| p c }
end</lang>
Line 91 ⟶ 93:
or
<lang ruby>File.open("input.txt
while c = file.read_char
p c
end
end</lang>
=={{header|Déjà Vu}}==
|