Etiket arşivi: Microsoft World

convert_smart_quotes

Microsoft World’e ait özel karakterleri temizlemek için,

function convert_smart_quotes($text){
$text = mb_convert_encoding($text, 'HTML-ENTITIES', 'UTF-8');

// UTF-8 karakteleri cevir
$text = str_replace(
array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"),
array("'", "'", '"', '"', '-', '--', '...'),
$text);

// Windows-1252 karakterleri cevir
$text = str_replace(
array(chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(133)),
array("'", "'", '"', '"', '-', '--', '...'),
$text);

// HTML Kod karakterlerini cevir
$text = str_replace(
array("‘", "’", "“", "”", "–", "—", "…"),
array("'", "'", '"', '"', '-', '--', '...'),
$text);

// Windows-1252 karakterleri cevir
$text = str_replace(
array("‘", "’", "“", "”", "–", "—", "…"),
array("'", "'", '"', '"', '-', '--', '...'),
$text);

// Turkce karakterleri cevir
$text = str_replace(
array("Ğ", "ğ", "Ö", "ö", "Ç", "ç", "Ş", "ş", "İ", "ı", "Ü", "ü"),
array("Ğ", "ğ", 'Ö', 'ö', 'Ç', 'ç', 'Ş', 'ş', 'İ', 'ı', 'Ü', 'ü'),
$text);

return $text;
}