Beispiel #1
0
 static function nonAsciiToEntities($s)
 {
     $sb = new StringBuf();
     $i = 0;
     $n = strlen($s);
     while ($i < $n) {
         $c = com_wiris_util_xml_WXmlUtils::getUtf8Char($s, $i);
         if ($c > 127) {
             $hex = com_wiris_common_WInteger::toHex($c, 5);
             $j = 0;
             while ($j < strlen($hex)) {
                 if (!(_hx_substr($hex, $j, 1) === "0")) {
                     $hex = _hx_substr($hex, $j, null);
                     break;
                 }
                 ++$j;
             }
             $sb->add("&#x" . $hex . ";");
             $i += strlen(com_wiris_util_xml_WXmlUtils_5($c, $hex, $i, $j, $n, $s, $sb));
             unset($j, $hex);
         } else {
             $sb->b .= chr($c);
             $i++;
         }
         unset($c);
     }
     return $sb->b;
 }
 static function nonAsciiToEntities($s)
 {
     $sb = new StringBuf();
     $i = 0;
     $n = strlen($s);
     while ($i < $n) {
         $c = com_wiris_util_xml_WXmlUtils::getUtf8Char($s, $i);
         if ($c > 127) {
             $sb->add("&#x" . com_wiris_common_WInteger::toHex($c, 5) . ";");
             $i += strlen(com_wiris_util_xml_WXmlUtils_5($c, $i, $n, $s, $sb));
         } else {
             $sb->b .= chr($c);
             $i++;
         }
         unset($c);
     }
     return $sb->b;
 }