UTF-8 encoding conversion todo list

This commit is contained in:
2013-10-11 17:30:06 +02:00
parent 5e088b808e
commit a72e2b146a
2 changed files with 49 additions and 5 deletions

View File

@@ -4495,6 +4495,21 @@ class ToolBox
return $asResult;
}
public static function utf8_compliant($sText)
{
if(strlen($sText) == 0) return true;
return (preg_match('/^.{1}/us', $sText, $ar) == 1);
}
/**
* Only works with ISO-8859-1 and UTF-8 encoding
*/
public static function strlen($sText)
{
if(utf8_compliant($sText)) return strlen(utf8_decode($sText));
else return strlen($sText);
}
}
/* Debug */