Java 类com.intellij.util.text.XmlCharsetDetector 实例源码

项目:consulo-xml    文件:HtmlFileType.java   
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();
}
项目:intellij-ce-playground    文件:HtmlFileType.java   
@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();
}
项目:intellij-ce-playground    文件:HtmlFileType.java   
@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);
}
项目:intellij-demandware    文件:ISMLFileType.java   
@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();
}
项目:intellij-demandware    文件:ISMLFileType.java   
@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);
}
项目:tools-idea    文件:HtmlFileType.java   
@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();
}
项目:tools-idea    文件:HtmlFileType.java   
@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);
}
项目:consulo-xml    文件:HtmlFileType.java   
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);
}
项目:intellij-ce-playground    文件:XmlUtil.java   
@Nullable
public static String extractXmlEncodingFromProlog(@NotNull byte[] content) {
  return XmlCharsetDetector.extractXmlEncodingFromProlog(content);
}
项目:intellij-ce-playground    文件:XmlUtil.java   
@Nullable
public static String extractXmlEncodingFromProlog(@NotNull CharSequence text) {
  return XmlCharsetDetector.extractXmlEncodingFromProlog(text);
}
项目:intellij-ce-playground    文件:XmlLikeFileType.java   
@Override
public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
  String charset = XmlCharsetDetector.extractXmlEncodingFromProlog(content);
  return charset == null ? CharsetToolkit.UTF8 : charset;
}
项目:intellij-ce-playground    文件:XmlLikeFileType.java   
@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;
}
项目:tools-idea    文件:XmlUtil.java   
@Nullable
public static String extractXmlEncodingFromProlog(final byte[] content) {
  return XmlCharsetDetector.extractXmlEncodingFromProlog(content);
}
项目:tools-idea    文件:XmlUtil.java   
@Nullable
public static String extractXmlEncodingFromProlog(String text) {
  return XmlCharsetDetector.extractXmlEncodingFromProlog(text);
}
项目:tools-idea    文件:XmlLikeFileType.java   
@Override
public String getCharset(@NotNull VirtualFile file, final byte[] content) {
  String charset = XmlCharsetDetector.extractXmlEncodingFromProlog(content);
  return charset == null ? CharsetToolkit.UTF8 : charset;
}
项目:tools-idea    文件:XmlLikeFileType.java   
@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;
}
项目:consulo-xml    文件:XmlUtil.java   
@Nullable
public static String extractXmlEncodingFromProlog(@NotNull byte[] content)
{
    return XmlCharsetDetector.extractXmlEncodingFromProlog(content);
}
项目:consulo-xml    文件:XmlUtil.java   
@Nullable
public static String extractXmlEncodingFromProlog(@NotNull CharSequence text)
{
    return XmlCharsetDetector.extractXmlEncodingFromProlog(text);
}