How do I write (raw) a binary string array representation to a file?
#str is a String not an Array
str = "[80, 75, 3, 4, 10, 0, 0, 0, 0, 0, -74, 121, 57, 64, 0, 0, 0, 0]"
File.open('/Users/file.zip', "wb") do |file|
file.write(str)
end
The code above does not work. How can I to fix it?
Most of the answers here assume you are using an Array, not a String as you stated (and as your example shows). This should work with the String you showed in the example:
Just make sure to
require 'json'.