public static function toPath($str, $options = null, $charset = 'UTF-8')
    {
        $options = self::_getOptions($options, array(
                    'extension' => '',
                    'spacereplace' => null,
                    'lengthlimit' => 2000,
                ));

        $str = trim(preg_replace('/(?:[^\w\-\.~\+% ]+|%(?![A-Fa-f0-9]{2}))/', '', self::toASCII($str, $charset)));
        $str = preg_replace('/\s+/', null === $options['spacereplace'] ? '' : $options['spacereplace'], $str);

        return substr($str, 0, $options['lengthlimit']).$options['extension'];
    }
public static function toPath($str, $options = null, $charset = 'UTF-8')
    {
        $options = self::_getOptions($options, array(
                    'extension' => '',
                    'spacereplace' => null,
                    'lengthlimit' => 2000,
                ));

        $str = trim(preg_replace('/(?:[^\w\-\.~\+% ]+|%(?![A-Fa-f0-9]{2}))/', '', self::toASCII($str, $charset)));
        $str = preg_replace('/\s+/', null === $options['spacereplace'] ? '' : $options['spacereplace'], $str);

        return substr($str, 0, $options['lengthlimit']).$options['extension'];
    }
public static function toPath ( $ str , $ options = null , $ charset = 'UTF-8' ) { $ options = self :: _getOptions ( $ options , array ( 'extension' => '' , 'spacereplace' => null , 'lengthlimit' => 2000 , ) ) ; $ str = trim ( preg_replace ( '/(?:[^\w\-\.~\+% ]+|%(?![A-Fa-f0-9]{2}))/' , '' , self :: toASCII ( $ str , $ charset ) ) ) ; $ str = preg_replace ( '/\s+/' , null === $ options [ 'spacereplace' ] ? '' : $ options [ 'spacereplace' ] , $ str ) ; return substr ( $ str , 0 , $ options [ 'lengthlimit' ] ) . $ options [ 'extension' ] ; }
Normalize a string to a valid path file name

@access public
@param  string $str     The string to normalize
@param  array  $options Convert options to use :
- extension      string The extension to concat to the converted string
- spacereplace   string The character replacement for space characters
- lengthlimit    int The max length of the returned string
@param  string $charset The default charset to use
@return string The converted string
Normalize a string to a valid path file name