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