Nasıl "é" dönüşümü yapmak

3 Cevap php

I have an XML ISO-8859-1 page, in which I have to output symbols like é.
If I output é it errors out. é works just fine.
So, what PHP function should I use to transform é to é

Bu büyük, eski kod (bazı önerecektir ve haklı yani varsayalım gibi) utf-8 hareket edemez.

3 Cevap

Buradaki yorumların bir göz deneyin; http://php.net/manual/en/function.htmlentities.php

phil at lavin dot me dot uk
08-Apr-2010 03:34 

The following will make a string completely safe for XML:

<?php
function philsXMLClean($strin) {
    $strout = null;

    for ($i = 0; $i < strlen($strin); $i++) {
            $ord = ord($strin[$i]);

            if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
                    $strout .= "&amp;#{$ord};";
            }
            else {
                    switch ($strin[$i]) {
                            case '<':
                                    $strout .= '&lt;';
                                    break;
                            case '>':
                                    $strout .= '&gt;';
                                    break;
                            case '&':
                                    $strout .= '&amp;';
                                    break;
                            case '"':
                                    $strout .= '&quot;';
                                    break;
                            default:
                                    $strout .= $strin[$i];
                    }
            }
    }

    return $strout;
}
?> 

Tüm krediler beni UK dot yok Lavin Phil gitmek

Kullan mb_convert_encoding:

mb_convert_encoding("é", "HTML-ENTITIES", "ISO-8859-1");

verir &#130;.

Bu örnek size veya ISO-8859-1 yapıyor olmayabilir "é", girmek gerektirmez:

mb_convert_encoding(chr(130), "HTML-ENTITIES", "ISO-8859-1");

var_dump(ord('é'));

Verir

int(233)

Belki, kullanabilirsiniz

print '&#' . ord('é') . ';';