added Str::ascii method and fixed accented character problem in URL::slug.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user