int e = snippet.getBuffer().indexOf(Parser.END_CHARSET_TOKEN, s);
AttributeTokenizer tokenizer = new AttributeTokenizer(snippet.getBuffer(), s, e, 1, 0);
Iterator ti = tokenizer.iterator();
while (ti.hasNext()) {
Map.Entry attribute = (Map.Entry) ti.next();
Token key = (Token) attribute.getKey();
//check the attribute name, we are only interested
//in "charset"
if (key != null && key.getRawText() != null
&& key.getRawText().equalsIgnoreCase("charset")) {
Token value = (Token) attribute.getValue();
//look for the value of the charset attribute
if (value != null && value.getRawText() != null) {
// if it is supported, use the value for the encoding
if (Charset.isSupported(value.getRawText())) {
enc = value.getRawText();
} else {
log.error(messages.getMessage("template.encoding.notsupported",
new Object[] { value.getRawText() }));
}
}
}
}
}