You may consider the binary representation of the TEXT
column by converting it to BYTEA
(edit: not by a direct cast, better use convert_to(text,'UTF-8')
instead) and searching the BOM sequence in it as a series of bytes.
as an SQL expression:
position('\xefbbbf'::bytea IN convert_to(your_text_column,'UTF-8'))=1
0
as the result of position(...)
would mean the BOM is not in the string.
1
means it's at the beginning of the string.