A BOM encoding was designed just to prevent that... But programmers are stubborn and forget these "little details" all the time. They are born like that....
Having a BOM wouldn't help the OP at all: the unique purpose of the BOM is to specify whether a Unicode file is LE or BE encoded and, indirectly, allows one to know if a file is Unicode text. Other than that ...
The OP's question is unsolvable: an array of characters may represent a string in almost any coceivable encoding and there is no simple way to "guess" which it might be. The only exceptions are the (relative) easy of guessing whether a file might be UTF8 and the even easier guess of a pure ASCII file.
Beyond that, how do you differentiate between Windoiws-1252, IBM-850 and IBM-437 encoded texts? You can't ... unless you have a nice expert system that can guess which language the text is and, by testing, the most probable encoding.