Skip to content

Instantly share code, notes, and snippets.

@mrluanma
Created November 19, 2010 09:25
Show Gist options
  • Save mrluanma/706287 to your computer and use it in GitHub Desktop.
Save mrluanma/706287 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
$KCODE = 'u'
require 'csv'
File.open('tmp.csv', 'wb') do |csv_file|
# 输出标明文本编码为 UTF-8 的 BOM
csv_file.write("\xEF\xBB\xBF")
CSV::Writer.generate(csv_file) do |csv|
csv << %w{第一 第二 第三}
csv << (1..3).to_a
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment