<?php

include '../root.class.php';
$db = new db_safeguard();

function normalize_spaces($string) {
    // Replace all Unicode space separators (including NBSP) with a normal space
    $string = preg_replace('/\s+/u', ' ', $string);

    // Also catch any special "space-like" characters that \s may not cover
    $string = str_replace(
        ["\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81", "\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84", "\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87", "\xE2\x80\x88", "\xE2\x80\x89", "\xE2\x80\x8A", "\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80"],
        ' ',
        $string
    );

    // Trim start and end
    return trim($string);
}

$res = $db->query('stock', "SELECT * FROM stock WHERE 1");

while ($row = $res->fetch_assoc()) {
    // if (mb_strpos($row['description'], '')) {
        echo $row['description'] . "<br>";
        // echo str_replace('Ø', 'O',  $row['description']) . "<br>";
        // $db->query('stock', "UPDATE stock SET `description` = '" . str_replace('Ø', 'O', $row['description']) . "' WHERE record_id = '" . $row['record_id'] . "'");
    // }
}

