How to get TextEdit to save with a ByteOrderMark?

I've saved files with different encodings using TextEdit. After closing the file, with a vim editor, I open the file and type the following to test for the existence of a byte order mark:

:setlocal bom?

no bom is detected for any encoding.

This script seems to directly create BOMs ok.

#!/usr/bin/env bash
printf '\xEF\xBB\xBF' > withBom.txt

But, I'd like to use a more reliable technique than that to create files with BOM. I don't understand what is going on with TextEdit.


Solution 1:

If I remember right, it's not possible in TextEdit. For BOM you need to use a more serious editor like BBEdit:

enter image description here