Ruby

該頁面還沒有翻譯。

Ruby是一個動態型別的程序設計語言

UTF-8支持

# coding: utf-8

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

文件輸入

# coding: utf-8

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

文件輸出

# coding: utf-8

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

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