Code Duplication    Length = 18-19 lines in 2 locations

src/voku/helper/Bootup.php 1 location

@@ 180-197 (lines=18) @@
177
      $s = str_replace(array("\r\n", "\r"), "\n", $s);
178
    }
179
180
    if (preg_match('/[\x80-\xFF]/', $s)) {
181
      if (Normalizer::isNormalized($s, $normalization_form)) {
182
        $n = '-';
183
      } else {
184
        $n = Normalizer::normalize($s, $normalization_form);
185
        if (isset($n[0])) {
186
          $s = $n;
187
        } else {
188
          $s = UTF8::encode('UTF-8', $s);
189
        }
190
      }
191
192
      if ($s[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $s)) {
193
        // Prevent leading combining chars
194
        // for NFC-safe concatenations.
195
        $s = $leading_combining . $s;
196
      }
197
    }
198
199
    return $s;
200
  }

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