Code Duplication    Length = 18-19 lines in 2 locations

src/voku/helper/Bootup.php 1 location

@@ 545-562 (lines=18) @@
542
      $s = str_replace(array("\r\n", "\r"), "\n", $s);
543
    }
544
545
    if (preg_match('/[\x80-\xFF]/', $s)) {
546
      if (Normalizer::isNormalized($s, $normalization_form)) {
547
        $n = '-';
548
      } else {
549
        $n = Normalizer::normalize($s, $normalization_form);
550
        if (isset($n[0])) {
551
          $s = $n;
552
        } else {
553
          $s = UTF8::encode('UTF-8', $s);
554
        }
555
      }
556
557
      if ($s[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $s)) {
558
        // Prevent leading combining chars
559
        // for NFC-safe concatenations.
560
        $s = $leading_combining . $s;
561
      }
562
    }
563
564
    return $s;
565
  }

src/voku/helper/UTF8.php 1 location

@@ 2568-2586 (lines=19) @@
2565
          // Workaround https://bugs.php.net/65732
2566
          $var = str_replace(array("\r\n", "\r"), "\n", $var);
2567
        }
2568
        if (preg_match('/[\x80-\xFF]/', $var)) {
2569
          if (Normalizer::isNormalized($var, $normalization_form)) {
2570
            $n = '-';
2571
          } else {
2572
            $n = Normalizer::normalize($var, $normalization_form);
2573
2574
            if (isset($n[0])) {
2575
              $var = $n;
2576
            } else {
2577
              $var = self::encode('UTF-8', $var);
2578
            }
2579
2580
          }
2581
          if ($var[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $var)) {
2582
            // Prevent leading combining chars
2583
            // for NFC-safe concatenations.
2584
            $var = $leading_combining . $var;
2585
          }
2586
        }
2587
        break;
2588
    }
2589