Hello got the following problems
First: if ÄÖÜ is provided with the regex the trademark sign replacement is producing a addional char �.:
Second: If I do a string loop through the result all special chars are �.
Question is, why is this happen, and what can I do against it? (Second question is not so nessesasary but interesting)
header('Content-Type: text/html; charset=utf-8');
$testtxt = 'MicrÖsüft W!ndows® is a trÄdemark of Microfrost™ ©2012!';
$r = preg_replace('#[^\w\s\däöüß%\!\?\.,\:\-_\[\]ÄÖÜ]#is', 'X', $testtxt);
echo $testtxt, '<br>', $r;
echo '<hr>';
for($i = 0, $size = strlen($r); $i < $size; ++$i) {
echo $r[$i], '=', ord($r[$i]), '<br>';
}
Result:
MicrÖsüft W!ndows® is a trÄdemark of Microfrost™ ©2012!
MicrÖsüft W!ndowsXX is a trÄdemark of MicrofrostX�X XX2012!
M=77
i=105
c=99
r=114
�=195
�=150....
Expected:
MicrÖsüft W!ndows® is a trÄdemark of Microfrost™ ©2012!
MicrÖsüft W!ndowsXX is a trÄdemark of MicrofrostXX XX2012!
M=77
i=105
c=99
r=114
Ö=195
s=150....