Bu durumun, ben genelde ben kelime kopya yapıştırdığınız dize ile başlar:
$str = 'Danâ’s back !';
var_dump($str);
And, going byte-by-byte in it, I output the hexadecimal code of each byte :
for ($i=0 ; $i<strlen($str) ; $i++) {
$byte = $str[$i];
$char = ord($byte);
printf('%s:0x%02x ', $byte, $char);
}
Hangi bunun gibi bir çıktı verir:
D:0x44 a:0x61 n:0x6e �:0xc3 �:0xa2 �:0xe2 �:0x80 �:0x99 s:0x73 :0x20 b:0x62 a:0x61 c:0x63 k:0x6b :0x20 !:0x21
Then, with a bit of guessing, luck, and trial-and-error, you'll find out that :
0xc3 0xa2: â iki bayt uyan bir karakter
- ve special-quote üç bayt uyan bir karakter:
0xe2 0x80 0x99
İpucu: Eğer birbirini izleyen iki özel karakterler yoksa zaman kolay ;-)
After that, it's only a matter of using str_replace to replace the correct sequence of bytes by another character ; for example, to replace the special-quote by a normal one :
var_dump(str_replace("\xe2\x80\x99", "'", $str));
Size verecektir:
string 'Danâ's back !' (length=14)