UTF-8 file is detected as ANSI.

To ensure UTF-8 detection under all circumstances, please use one of thw following strategies:

Technical explanation of how UTF-8 is detected

While files encoded in UTF-8 with BOM contain BOM (Byte Order Mask) which is an invisible string of bytes that acts as an indicator that the file contains UTF-8 text, files encoded in UTF-8 without BOM do not contain this indicator and the only way of detection is analyzing the contents of the file.

According to the UTF-8 specification, UTF-8 text is simply an ANSI text where each language-specific character is replaced by two special (human-unreadable) characters which are displayed as a single readable language-specific character when the file is open in a compatible editor. This means that an UTF-8 file with no language-specific characters actually IS an ANSI file and there is no way to tell otherwise unless the file contains BOM or some other valid indication, such as HTML meta encoding tag.