Skip to content

Instantly share code, notes, and snippets.

@shigeyas
Created October 4, 2012 02:11
Show Gist options
  • Save shigeyas/3831090 to your computer and use it in GitHub Desktop.
Save shigeyas/3831090 to your computer and use it in GitHub Desktop.
Ruby 'gaiji' conversion sample
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
ú±
ŒÃûP
ûM–{
úºO
ûM“c
ûü‹´
# -*- coding: utf-8 -*-
#
line = 1
open("enc-test.csv", "r:Shift_JIS").each do |s|
begin
u = s.encode("utf-8", undef: :replace)
r = "OK"
rescue => e
r = "NG"
u = "" # not to print unprintable
end
puts ">> #{r} #{line} #{u}"
line += 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment