Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anvyzhang/9408f53ec10d7e58a6f531b451b5525d to your computer and use it in GitHub Desktop.
Save anvyzhang/9408f53ec10d7e58a6f531b451b5525d 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