Ruby

This page has not been translated.

Ruby is a dynamic typing Programming language.

UTF-8 support

# coding: utf-8

s1 = "\u3042いうえお"
s2 = "abcdefg"
puts s1          # あいうえお
puts s1.encoding # UTF-8
puts s2.encoding # UTF-8
puts s1.size     # 5

File input

# coding: utf-8

File.open("hoge.txt") do |f|
  f.each_line do |line|
    puts line
  end
end

File output

# coding: utf-8

File.open("hoge.txt", "w") do |f|
  f.puts "あいうえお"
end

File.open("hoge.txt", "a") do |f|
  f.puts "かきくけこ"
end