1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/doc/examples/files.rdoc
Burdette Lamar 56d773dc6f
New page IO Streams (#6383)
This page provides an overview of IO streams. It's meant to be linked to from many other doc spots. In particular it will be linked to from many places in ARGF, File, IO, and StringIO.
2022-09-21 16:34:55 -05:00

26 lines
404 B
Text

# English text with newlines.
text = <<~EOT
First line
Second line
Fourth line
Fifth line
EOT
# Russian text.
russian = "\u{442 435 441 442}" # => "тест"
# Binary data.
data = "\u9990\u9991\u9992\u9993\u9994"
# Text file.
File.write('t.txt', text)
# File with Russian text.
File.write('t.rus', russian)
# File with binary data.
f = File.new('t.dat', 'wb:UTF-16')
f.write(data)
f.close