Charset (@Nullable Project project, @Nullable VirtualFile file, @NotNull CharSequence content) { final String charsetName = getCharsetFromEncodingDeclaration(content); if (charsetName == null) { return null; } try { return Charset.forName(charsetName); } catch (IllegalCharsetNameException | UnsupportedCharsetException e) { return null; } }