String (@NotNull VirtualFile file, byte @NotNull [] content) { if (CharsetToolkit.hasUTF8Bom(content)) { return CharsetToolkit.UTF8; } ByteBuffer bytes = ByteBuffer.wrap(content, 0, Math.min(256, content.length)); String decoded = StandardCharsets.UTF_8.decode(bytes).toString(); return getCharsetFromEncodingDeclaration(StringUtil.convertLineSeparators(decoded)); }