Android HTML Charset Get getHtmlCharset(String content)

Here you can find the source of getHtmlCharset(String content)

Description

get Html Charset

Declaration

public static String getHtmlCharset(String content) 

Method Source Code

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

    public static String getHtmlCharset(String content) {
        String encoding = null;//from   w  ww.j a  v a  2 s. c  o m
        final String CHARSET_REGX = "<meta.*charset=\"?([a-zA-Z0-9-_/]+)\"?";
        Matcher m = Pattern.compile(CHARSET_REGX).matcher(content);
        if (m.find()) {
            encoding = m.group(1);
        }
        return encoding;
    }
}