Charset (@Nullable Project project, byte @NotNull [] content, @Nullable FileType fileType, @NotNull @NonNls @SystemIndependent String lightFilePath, @Nullable VirtualFile highlightFile, @Nullable Charset defaultCharset) { Charset bomCharset = CharsetToolkit.guessFromBOM(content); if (bomCharset != null) return bomCharset; if (defaultCharset != null) return defaultCharset; if (fileType != null && !fileType.isBinary()) { Charset fileTypeCharset = guessFileTypeCharset(project, content, fileType, lightFilePath); if (fileTypeCharset != null) return fileTypeCharset; } if (highlightFile != null) { Charset fileCharset = highlightFile.getCharset(); return takeCharsetOrGuessUTF(fileCharset, content); } else { EncodingManager e = project != null ? EncodingProjectManager.getInstance(project) : EncodingManager.getInstance(); Charset globalCharset = e.getDefaultCharset(); return takeCharsetOrGuessUTF(globalCharset, content); } }