in reply to help neeed in identifying file encoding

You are using the numeric equality operator == to compare strings. Most strings numify to 0, so you end up testing a 0 == 0, which is true. Use the string equality operator eq instead.

That won’t work either, though, since under use bytes your chr 0xFEFF will simply produce chr 0xFF – not what you’re looking for.

Makeshifts last the longest.