added Str::ascii method and fixed accented character problem in URL::slug.

This commit is contained in:
Taylor Otwell
2011-07-30 09:52:49 -05:00
parent 86075c2765
commit 481d2aa7ec
3 changed files with 90 additions and 0 deletions

View File

@@ -57,6 +57,21 @@ class Str {
return function_exists('mb_strlen') ? mb_strlen($value, Config::get('application.encoding')) : strlen($value);
}
/**
* Convert a string to 7-bit ASCII.
*
* @param string $value
* @return string
*/
public static function ascii($value)
{
$foreign = Config::get('ascii');
$value = preg_replace(array_keys($foreign), array_values($foreign), $value);
return preg_replace('/[^\x09\x0A\x0D\x20-\x7E]/', '', $value);
}
/**
* Generate a random alpha or alpha-numeric string.
*