Skip to content

Commit

Permalink
Another method
Browse files Browse the repository at this point in the history
  • Loading branch information
silasb committed May 15, 2019
1 parent f195ed6 commit 6becba8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions spec/csv-to-json_spec.cr
Expand Up @@ -96,14 +96,13 @@ describe Csv::To::Json do

it "will parse bad_data.tsv fixture" do
in_io = File.open("spec/fixtures/bad_data.tsv")
in_io.set_encoding(encoding: "latin1")
out_io = IO::Memory.new()

Csv::To::Json.run(in_io, out_io)

out_io.seek(0)
# puts String.new(out_io.peek)
# out_io.peek.each { |s| puts s.to_char }
out_io.to_s.should contain(%([\n{"field 1":"Associao Paulista de Cirurgies-Den"}\n]\n))
out_io.to_s.should contain(%([\n{"field 1":"Associação Paulista de Cirurgiões-Den"}\n]\n))
end

it "will parse \u0041 char" do
Expand Down
2 changes: 1 addition & 1 deletion src/csv-to-json.cr
Expand Up @@ -7,7 +7,7 @@ module Csv::To::Json
def self.run(in_io, out_io, options = {} of Symbol => String)
STDIN.blocking = true

in_io.set_encoding(encoding: "UTF-8", invalid: :skip)
# in_io.set_encoding(encoding: "UTF-8", invalid: :skip)

empty_value_replace_char = options.fetch(:empty_value_replace_char, "")
tail = options.delete :tail
Expand Down

0 comments on commit 6becba8

Please sign in to comment.