|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * Demojibakefier (last modified: 2026.03.18). |
| 3 | + * Demojibakefier (last modified: 2026.03.20). |
4 | 4 | * |
5 | 5 | * Intended to normalise the character encoding of a given string to a |
6 | 6 | * preferred character encoding when the given string's byte sequences don't |
@@ -329,7 +329,7 @@ public function shannonEntropy(string $String) |
329 | 329 | } |
330 | 330 | $Total = 0; |
331 | 331 | foreach ($Chars as $Char) { |
332 | | - $Total += abs(($Char / $Len) * log(($Char / $Len), 2)); |
| 332 | + $Total += \abs(($Char / $Len) * \log(($Char / $Len), 2)); |
333 | 333 | } |
334 | 334 | return $Total; |
335 | 335 | } |
@@ -363,11 +363,11 @@ public function normalise(string $String): string |
363 | 363 | if (!$this->checkConformity($String, $Encoding)) { |
364 | 364 | continue; |
365 | 365 | } |
366 | | - $Attempt = iconv($Encoding, $this->NormaliseTo, $String); |
| 366 | + $Attempt = \iconv($Encoding, $this->NormaliseTo, $String); |
367 | 367 | if ($Attempt === false || !$this->checkConformity($Attempt, $this->NormaliseTo)) { |
368 | 368 | continue; |
369 | 369 | } |
370 | | - if (\strcmp(iconv($this->NormaliseTo, $Encoding, $Attempt), $String) === 0) { |
| 370 | + if (\strcmp(\iconv($this->NormaliseTo, $Encoding, $Attempt), $String) === 0) { |
371 | 371 | $Valid[$Encoding] = $Attempt; |
372 | 372 | if ($Encoding === $this->NormaliseTo) { |
373 | 373 | break; |
@@ -563,7 +563,7 @@ private function weigh(string $String, array &$Arr): void |
563 | 563 | } |
564 | 564 |
|
565 | 565 | $RateAZ = \preg_match_all('~[\x41-\x5A\x61-\x7A]~', $String) / $this->Len; |
566 | | - $EntrAZ = \round(abs($RateAZ * log($RateAZ, 2)), 2); |
| 566 | + $EntrAZ = \round(\abs($RateAZ * \log($RateAZ, 2)), 2); |
567 | 567 |
|
568 | 568 | /** More common versus less common byte sequences in 1-byte encodings. */ |
569 | 569 | foreach ([ |
@@ -591,7 +591,7 @@ private function weigh(string $String, array &$Arr): void |
591 | 591 | ] as $Encoding => $Bytes) { |
592 | 592 | if (isset($Arr[$Encoding]['Weight'])) { |
593 | 593 | $RateThis = \preg_match_all('~' . $Bytes . '~', $String) / $this->Len; |
594 | | - $EntrThis = \round(abs($RateThis * log($RateThis, 2)), 2); |
| 594 | + $EntrThis = \round(\abs($RateThis * \log($RateThis, 2)), 2); |
595 | 595 | if ($EntrThis !== $EntrAZ) { |
596 | 596 | $Arr[$Encoding]['Weight'] += ($EntrThis > $EntrAZ) ? 0.5 : -0.5; |
597 | 597 | } |
|
0 commit comments