public String getCharset(@NotNull final VirtualFile file, final byte[] content) { String charset = XmlCharsetDetector.extractXmlEncodingFromProlog(content); if(charset != null) { return charset; } @NonNls String strContent; try { strContent = new String(content, "ISO-8859-1"); } catch(UnsupportedEncodingException e) { return null; } Charset c = HtmlUtil.detectCharsetFromMetaTag(strContent); return c == null ? null : c.name(); }
@Override public String getCharset(@NotNull final VirtualFile file, @NotNull final byte[] content) { String charset = XmlCharsetDetector.extractXmlEncodingFromProlog(content); if (charset != null) return charset; @NonNls String strContent; try { strContent = new String(content, "ISO-8859-1"); } catch (UnsupportedEncodingException e) { return null; } Charset c = HtmlUtil.detectCharsetFromMetaTag(strContent); return c == null ? null : c.name(); }
@Override public Charset extractCharsetFromFileContent(@Nullable final Project project, @Nullable final VirtualFile file, @NotNull final CharSequence content) { String name = XmlCharsetDetector.extractXmlEncodingFromProlog(content); Charset charset = CharsetToolkit.forName(name); if (charset != null) { return charset; } return HtmlUtil.detectCharsetFromMetaTag(content); }
@Override public String getCharset(@NotNull final VirtualFile file, final byte[] content) { String charset = XmlCharsetDetector.extractXmlEncodingFromProlog(content); if (charset != null) return charset; @NonNls String strContent; try { strContent = new String(content, "ISO-8859-1"); } catch (UnsupportedEncodingException e) { return null; } Charset c = HtmlUtil.detectCharsetFromMetaHttpEquiv(strContent); return c == null ? null : c.name(); }
@Override public Charset extractCharsetFromFileContent(@Nullable final Project project, @Nullable final VirtualFile file, @NotNull final String content) { String name = XmlCharsetDetector.extractXmlEncodingFromProlog(content); Charset charset = CharsetToolkit.forName(name); if (charset != null) { return charset; } return HtmlUtil.detectCharsetFromMetaHttpEquiv(content); }
public Charset extractCharsetFromFileContent(@Nullable final Project project, @Nullable final VirtualFile file, @NotNull final CharSequence content) { String name = XmlCharsetDetector.extractXmlEncodingFromProlog(content); Charset charset = CharsetToolkit.forName(name); if(charset != null) { return charset; } return HtmlUtil.detectCharsetFromMetaTag(content); }
@Nullable public static String extractXmlEncodingFromProlog(@NotNull byte[] content) { return XmlCharsetDetector.extractXmlEncodingFromProlog(content); }
@Nullable public static String extractXmlEncodingFromProlog(@NotNull CharSequence text) { return XmlCharsetDetector.extractXmlEncodingFromProlog(text); }
@Override public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) { String charset = XmlCharsetDetector.extractXmlEncodingFromProlog(content); return charset == null ? CharsetToolkit.UTF8 : charset; }
@Override public Charset extractCharsetFromFileContent(final Project project, @Nullable final VirtualFile file, @NotNull final CharSequence content) { String name = XmlCharsetDetector.extractXmlEncodingFromProlog(content); Charset charset = CharsetToolkit.forName(name); return charset == null ? CharsetToolkit.UTF8_CHARSET : charset; }
@Nullable public static String extractXmlEncodingFromProlog(final byte[] content) { return XmlCharsetDetector.extractXmlEncodingFromProlog(content); }
@Nullable public static String extractXmlEncodingFromProlog(String text) { return XmlCharsetDetector.extractXmlEncodingFromProlog(text); }
@Override public String getCharset(@NotNull VirtualFile file, final byte[] content) { String charset = XmlCharsetDetector.extractXmlEncodingFromProlog(content); return charset == null ? CharsetToolkit.UTF8 : charset; }
@Override public Charset extractCharsetFromFileContent(final Project project, @Nullable final VirtualFile file, @NotNull final String content) { String name = XmlCharsetDetector.extractXmlEncodingFromProlog(content); Charset charset = CharsetToolkit.forName(name); return charset == null ? CharsetToolkit.UTF8_CHARSET : charset; }