I have a stream that I'm reading from and in turn am writing to a file however I am getting an error that is caused by the presence of a ’
. I assume this is because I'm opening the file w/ the wrong encoding or something but I don't know how to properly set it:
file = File.open!("/some/path.csv", [:write])
IO.write(file, "’")
This results in the following error:
** (ErlangError) erlang error: :no_translation (stdlib) :io.put_chars(#PID<0.250.0>, :unicode, "’")
You should open the file in :utf8
mode.
file = File.open!("/tmp/foo.txt", [:write, :utf8])
IO.write(file, "’")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With