20 protected $_aUmls = array(
"\xc3\xa4",
"\xc3\xb6",
"\xc3\xbc",
"\xC3\x84",
"\xC3\x96",
"\xC3\x9C",
"\xC3\x9F" );
26 protected $_aUmlEntities = array(
'ä',
'ö',
'ü',
'Ä',
'Ö',
'Ü',
'ß' );
46 return mb_strlen($sStr, $this->_sEncoding);
58 public function substr( $sStr, $iStart, $iLength = null )
60 $iLength = is_null( $iLength ) ? $this->
strlen( $sStr ) : $iLength;
61 return mb_substr( $sStr, $iStart, $iLength, $this->_sEncoding );
73 public function strpos( $sHaystack, $sNeedle, $iOffset = null )
76 if ( $sHaystack && $sNeedle ) {
77 $iOffset = is_null( $iOffset ) ? 0 : $iOffset;
78 $iPos = mb_strpos( $sHaystack, $sNeedle, $iOffset, $this->_sEncoding );
91 public function strstr( $sHaystack, $sNeedle )
97 return mb_strstr($sHaystack, $sNeedle,
false, $this->_sEncoding);
109 return mb_strtolower($sString, $this->_sEncoding);
121 return mb_strtoupper($sString, $this->_sEncoding);
145 return htmlentities($sString, ENT_QUOTES, $this->_sEncoding);
170 public function preg_split($sPattern, $sString, $iLimit = -1, $iFlag = 0)
172 return preg_split( $sPattern.
'u', $sString, $iLimit, $iFlag );
186 public function preg_replace($aPattern, $sString, $sSubject, $iLimit = -1, $iCount = null)
188 if ( is_array($aPattern) ) {
189 foreach ( $aPattern as &$sPattern) {
190 $sPattern = $sPattern.
'u';
193 $aPattern = $aPattern.
'u';
195 return preg_replace( $aPattern, $sString, $sSubject, $iLimit, $iCount);
209 public function preg_match($sPattern, $sSubject, &$aMatches = null, $iFlags = null, $iOffset = null)
211 return preg_match( $sPattern.
'u', $sSubject, $aMatches, $iFlags, $iOffset);
225 public function preg_match_all($sPattern, $sSubject, &$aMatches = null, $iFlags = null, $iOffset = null)
227 return preg_match_all( $sPattern.
'u', $sSubject, $aMatches, $iFlags, $iOffset);
240 return $sString . $this->
substr($sSubject, 1);
253 public function wordwrap( $sString, $iLength = 75, $sBreak =
"\n", $blCut = null )
256 $sRegexp =
"/^(.{1,{$iLength}}\r?(\s|$|\n)|.{1,{$iLength}}[^\r\s\n]*\r?(\n|\s|$))/u";
258 $sRegexp =
"/^([^\s]{{$iLength}}|.{1,{$iLength}}\s)/u";
261 $iStrLen = mb_strlen( $sString, $this->_sEncoding );
262 $iWraps = floor( $iStrLen / $iLength );
268 $iWraps = floor( mb_strlen( $sString, $this->_sEncoding ) / $iLength );
271 if (
preg_match( $sRegexp, $sString, $aMatches ) ) {
272 $sStr = $aMatches[0];
273 $sReturn .=
preg_replace(
'/\s$/s',
'', $sStr ) . $sBreak;
274 $sString = $this->
substr( $sString, mb_strlen( $sStr, $this->_sEncoding ) );
282 $sReturn .= $sBreak.$sString;
299 public function recodeEntities( $sInput, $blToHtmlEntities =
false, $aUmls = array(), $aUmlEntities = array() )
301 $aUmls = ( count( $aUmls ) > 0 ) ? array_merge( $this->_aUmls, $aUmls) :
$this->_aUmls;
302 $aUmlEntities = ( count( $aUmlEntities ) > 0 ) ? array_merge( $this->_aUmlEntities, $aUmlEntities) :
$this->_aUmlEntities;
303 return $blToHtmlEntities ? str_replace( $aUmls, $aUmlEntities, $sInput ) : str_replace( $aUmlEntities, $aUmls, $sInput );
315 return $this->
preg_match(
"/(".implode(
"|", $this->_aUmls ).
"|(&))/", $sStr );
327 public function cleanStr( $sStr, $sCleanChr =
' ' )
329 return $this->
preg_replace(
"/\n|\r|\t|\xc2\x95|\xc2\xa0|;/", $sCleanChr, $sStr );
341 return json_encode($data);
354 if ( stripos( $sAllowableTags,
'<style>' ) ===
false ) {
356 $sString = $this->
preg_replace(
"'<style[^>]*>.*</style>'siU",
'', $sString );
358 return strip_tags( $sString, $sAllowableTags );
372 return -strcmp( $sStr1, $sStr2 );