public static function escapeXml()

in src/Utils.php [210:248]


    public static function escapeXml(string $s): string
    {
        $result = '';
        $length = strlen($s);
        for ($i = 0; $i < $length; $i++) {
            $d = $s[$i];
            switch ($d) {
                case '"';
                    $result .= '&quot;';
                    break;
                case '&';
                    $result .= '&amp;';
                    break;
                case '<';
                    $result .= '&lt;';
                    break;
                case '>';
                    $result .= '&gt;';
                    break;
                case "\t";
                    $result .= '&#09;';
                    break;
                case "\n";
                    $result .= '&#10;';
                    break;
                case "\r";
                    $result .= '&#13;';
                    break;
                default:
                    $n = ord($d);
                    if ($n < 0x20) {
                        $result .= sprintf('&#%02d;', $n);
                    } else {
                        $result .= $d;
                    }
            }
        }
        return $result;
    }