package railo.commons.io;

import java.nio.charset.Charset;

import railo.runtime.exp.PageException;
import railo.runtime.op.Caster;

public class CharsetUtil {

	public static Charset toCharset(String charset) throws PageException {
		try{
			return Charset.forName(charset);
		}
		catch(Throwable t){
			throw Caster.toPageException(t);
		}
	}

	public static Charset toCharset(String charset,Charset defaultValue) {
		try{
			return Charset.forName(charset);
		}
		catch(Throwable t){
			return defaultValue;
		}
	}

}

@@ -153,16 +153,178 @@
 etUtil %7B
+%0A%09public static final Charset UTF8;%0A%09public static final Charset ISO88591;%0A%09%0A%09static %7B%0A%09%09UTF8=toCharset(%22utf-8%22,null);%0A%09%09ISO88591=toCharset(%22iso-8859-1%22,null);%0A%09%7D
 %0A%0A%09publi

add constants for charsets