Pārlūkot izejas kodu

fix. function is broken if it runs on string without html entities

tokul 21 gadi atpakaļ
vecāks
revīzija
0dbcdf47ba
1 mainītis faili ar 4 papildinājumiem un 0 dzēšanām
  1. 4 0
      functions/encode/utf_8.php

+ 4 - 0
functions/encode/utf_8.php

@@ -20,6 +20,10 @@
  * @return a utf-8 encoded string [STRING]
  */
 function charset_encode_utf_8 ($source) {
+
+   // don't run though encoding function, if there is no encoded characters
+   if (! preg_match("'&#'",$source) ) return $source;
+
    $utf8Str = '';
    $entityArray = explode ("&#", $source);
    $size = count ($entityArray);