Maybe I should re-write my original problem:
The function "file_str_readtow" which reads text files doesn't properly processes those files and adds the file's metadata to the content. I think you should fix file_str_readtow so that it discards that BOM. Even better, it can use it so the engine can process both little-endian and big-endian text files.