How to encoding the file except utf-8 when exporting a csv file?

When exporting the csv file, it is automatically encoding as utf-8.
I want to do encoding other than utf-8, is there a way?

File.open(filepath, "wb:ISO-8859-1") do |file|
  file.puts my_iso_8859_1_string
end
2 Likes

REF:

https://ruby-doc.org/core-2.7.2/Encoding.html#class-Encoding-label-IO+encoding+example