public static function encode_fn($file,$safe=true)
    {
        if($safe && preg_match('#^[a-zA-Z0-9/_\-.%]+$#',$file)){
            return $file;
        }
        $file = urlencode($file);
        $file = str_replace('%2F','/',$file);
        return $file;
    }
public static function encode_fn($file,$safe=true)
    {
        if($safe && preg_match('#^[a-zA-Z0-9/_\-.%]+$#',$file)){
            return $file;
        }
        $file = urlencode($file);
        $file = str_replace('%2F','/',$file);
        return $file;
    }
public static function encode_fn ( $ file , $ safe = true ) { if ( $ safe && preg_match ( '#^[a-zA-Z0-9/_\-.%]+$#' , $ file ) ) { return $ file ; } $ file = urlencode ( $ file ) ; $ file = str_replace ( '%2F' , '/' , $ file ) ; return $ file ; }
URL-Encode a filename to allow unicodecharacters

Slashes are not encoded

When the second parameter is true the string will
be encoded only if non ASCII characters are detected -
This makes it safe to run it multiple times on the
same string (default is true)

@author Andreas Gohr <andi@splitbrain.org>
@see    urlencode
URL - Encode a filename to allow unicodecharacters