Revision: 224
http://sourceforge.net/p/beeframework/code/224
Author: m_plomer
Date: 2014-09-22 09:01:40 +0000 (Mon, 22 Sep 2014)
Log Message:
-----------
- changes to Bee_Utils_Strings::toAscii
Modified Paths:
--------------
branches/0.9-dev/framework/Bee/Utils/Strings.php
Modified: branches/0.9-dev/framework/Bee/Utils/Strings.php
===================================================================
--- branches/0.9-dev/framework/Bee/Utils/Strings.php 2014-09-22 08:59:52 UTC (rev 223)
+++ branches/0.9-dev/framework/Bee/Utils/Strings.php 2014-09-22 09:01:40 UTC (rev 224)
@@ -213,12 +213,13 @@
*
* @return string
*/
- public static function toAscii($string, $table=array(), $delimiter='-', $toLowercase=true) {
+ public static function toAscii($string, $table=array(), $delimiter='-', $toLowercase=true, $allowEmailChars=false) {
if (count($table)>0) {
$string = strtr($string, $table);
}
$ascii = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
- $ascii = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $ascii);
+ $emailChars = $allowEmailChars ? '@.' : '';
+ $ascii = preg_replace("/[^a-zA-Z0-9\/_|+ -".$emailChars."]/", '', $ascii);
$ascii = trim($ascii, '-');
$ascii = preg_replace("/[\/_|+ -]+/", $delimiter, $ascii);
return $toLowercase ? strtolower($ascii) : $ascii;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|