I have some working code with a crutch to add BOM marker to a new file.

  #writing
  File.open name, 'w', 0644 do |file|
    file.write "\uFEFF"
    file.write @data
  end

  #reading
  File.open name, 'r:bom|utf-8' do |file|
    file.read
  end

Is there any way to automatically add the marker without writing cryptic "\uFEFF" before the data? Something like File.open name, 'w:bom' # this mode has no effect maybe?

Edit
Report