Interpret a comma seperated list of ints as a string

Getting input like 100,101,102,103 and knowing it is supposed to represent characters but all you have is the bytes can be annoying, so here we go a quick way of writing it out as a text file.

File.open("out.txt", "w") do |f|
  content = File.open("bytes.csv").read
  f.write(content.split(",").map(&:to_i).pack("c*"))
end

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.