001 package railo.runtime.functions.international; 002 003 import java.io.UnsupportedEncodingException; 004 005 import railo.runtime.PageContext; 006 import railo.runtime.exp.FunctionException; 007 import railo.runtime.exp.PageException; 008 import railo.runtime.ext.function.Function; 009 import railo.runtime.op.Caster; 010 011 /** 012 * Implements the Cold Fusion Function setlocale 013 */ 014 public final class SetEncoding implements Function { 015 016 public static String call(PageContext pc , String scope, String charset) throws PageException { 017 scope=scope.trim().toLowerCase(); 018 try { 019 if(scope.equals("url"))(pc.urlScope()).setEncoding(charset); 020 else if(scope.equals("form"))(pc.formScope()).setEncoding(charset); 021 else throw new FunctionException(pc,"setEncoding",1,"scope","scope must have the one of the following values [url,from] not ["+scope+"]"); 022 023 } catch (UnsupportedEncodingException e) { 024 throw Caster.toPageException(e); 025 } 026 return ""; 027 } 028 029 030 }