1
votes

So in application i'm generating xml content as strings:

content = []
content << '<?xml version="1.0" encoding="UTF-8" ?>'

etc.

I know that UTF-8 BOM files are marked with 3 bytes at the start of the file: '0xEF,0xBB,0xBF'. How do I include those bytes so file would be UTF-8 with BOM

1

1 Answers

0
votes
File.open('file.xml', 'ab:utf-8') do |io|
  io.write("\xEF\xBB\xBF")
  io.write(xml_data)
end