Expand mojibake repair to punctuation and symbols
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Mojibake Repair (Temporary)
|
||||
* Description: Previews and repairs Czech UTF-8 mojibake while preserving serialized WordPress settings.
|
||||
* Version: 1.1.0
|
||||
* Description: Previews and repairs Czech text and punctuation mojibake while preserving serialized WordPress settings.
|
||||
* Version: 1.1.1
|
||||
* Requires PHP: 7.4
|
||||
*/
|
||||
|
||||
@@ -14,7 +14,7 @@ final class WP_Mojibake_Repair_Temporary
|
||||
const SAMPLE_LIMIT = 5;
|
||||
const SAMPLE_LENGTH = 300;
|
||||
const APPROVAL_TTL = 600;
|
||||
const REPAIR_VERSION = 2;
|
||||
const REPAIR_VERSION = 3;
|
||||
const BATCH_SIZE = 200;
|
||||
|
||||
public static function init()
|
||||
@@ -297,7 +297,11 @@ final class WP_Mojibake_Repair_Temporary
|
||||
0x98 => '˜', 0x99 => '™', 0x9a => 'š', 0x9b => '›', 0x9c => 'œ',
|
||||
0x9e => 'ž', 0x9f => 'Ÿ',
|
||||
);
|
||||
foreach (preg_split('//u', 'áčďéěíňóřšťúůýžÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ', -1, PREG_SPLIT_NO_EMPTY) as $letter) {
|
||||
// Only these target characters generate replacements. The Windows
|
||||
// table above describes misdecoded bytes; it is not a target list.
|
||||
$targets = 'áčďéěíňóřšťúůýžÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ'
|
||||
. '–—‘’‚“”„…•«»‹›€™©®°' . "\xc2\xa0"; // Nonbreaking space.
|
||||
foreach (preg_split('//u', $targets, -1, PREG_SPLIT_NO_EMPTY) as $letter) {
|
||||
$latin = '';
|
||||
$cp1252 = '';
|
||||
foreach (unpack('C*', $letter) as $byte) {
|
||||
@@ -464,7 +468,7 @@ final class WP_Mojibake_Repair_Temporary
|
||||
{
|
||||
echo '<h2>Preview</h2>';
|
||||
echo '<p><strong>' . number_format_i18n($preview['total']) . '</strong> differing column values found. Only the samples below will be displayed; the confirmed update covers all counted candidates.</p>';
|
||||
echo '<p>Only recognized Czech mojibake sequences are replaced. Correct Unicode is preserved, and serialized string lengths are updated. Review the samples to confirm that these replacements match your content.</p>';
|
||||
echo '<p>Only recognized mojibake sequences for Czech letters, common punctuation, symbols and nonbreaking spaces are replaced. Correct Unicode is preserved, and serialized string lengths are updated. Review the samples to confirm that these replacements match your content.</p>';
|
||||
if ($preview['skipped'] > 0) {
|
||||
echo '<div class="notice notice-warning"><p><strong>' . number_format_i18n($preview['skipped']) . ' values were skipped.</strong> They contain repair candidates but have malformed or unsupported data (such as serialized objects or references). Already broken settings need recovery from a backup.</p></div>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user