}
// Get rid of cruft around names, like <>, trailing commas, etc.
Matcher m = CHARSET_NAME_PATTERN.matcher(name);
if (!m.matches()) {
throw new IllegalCharsetNameException(name);
}
name = m.group(1);
String lower = name.toLowerCase(Locale.ENGLISH);
Charset charset = COMMON_CHARSETS.get(lower);
if (charset != null) {
return charset;
} else if ("none".equals(lower) || "no".equals(lower)) {
throw new IllegalCharsetNameException(name);
} else {
Matcher iso = ISO_NAME_PATTERN.matcher(lower);
Matcher cp = CP_NAME_PATTERN.matcher(lower);
Matcher win = WIN_NAME_PATTERN.matcher(lower);
if (iso.matches()) {