Reputation: 471
I want to do like this:
File.open("file.txt","w+") do |f1|
f1.write(" °C")
end
but it has an error because of "°" , how can I do fix this?
Upvotes: 2
Views: 714
Reputation: 168139
If you are using Ruby < 2.0, then put this magic comment at the beginning of that file:
# coding: utf-8
If that does not work, then delete the file "file.txt"
once, and try again. The file may not be compatible with the encoding.
Upvotes: 2