src/Thujohn/Pdf/dompdf/lib/html5lib/Data.php
public static function utf8chr($code) {
        /* We don't care: we live dangerously
         * if($code > 0x10FFFF or $code < 0x0 or
          ($code >= 0xD800 and $code <= 0xDFFF) ) {
            // bits are set outside the "valid" range as defined
            // by UNICODE 4.1.0
            return "\xEF\xBF\xBD";
          }*/

        $x = $y = $z = $w = 0;
        if ($code < 0x80) {
            // regular ASCII character
            $x = $code;
        } else {
            // set up bits for UTF-8
            $x = ($code & 0x3F) | 0x80;
            if ($code < 0x800) {
               $y = (($code & 0x7FF) >> 6) | 0xC0;
            } else {
                $y = (($code & 0xFC0) >> 6) | 0x80;
                if($code < 0x10000) {
                    $z = (($code >> 12) & 0x0F) | 0xE0;
                } else {
                    $z = (($code >> 12) & 0x3F) | 0x80;
                    $w = (($code >> 18) & 0x07) | 0xF0;
                }
            }
        }
        // set up the actual character
        $ret = '';
        if($w) $ret .= chr($w);
        if($z) $ret .= chr($z);
        if($y) $ret .= chr($y);
        $ret .= chr($x);

        return $ret;
    }
public static function utf8chr($code) {
        /* We don't care: we live dangerously
         * if($code > 0x10FFFF or $code < 0x0 or
          ($code >= 0xD800 and $code <= 0xDFFF) ) {
            // bits are set outside the "valid" range as defined
            // by UNICODE 4.1.0
            return "\xEF\xBF\xBD";
          }*/

        $x = $y = $z = $w = 0;
        if ($code < 0x80) {
            // regular ASCII character
            $x = $code;
        } else {
            // set up bits for UTF-8
            $x = ($code & 0x3F) | 0x80;
            if ($code < 0x800) {
               $y = (($code & 0x7FF) >> 6) | 0xC0;
            } else {
                $y = (($code & 0xFC0) >> 6) | 0x80;
                if($code < 0x10000) {
                    $z = (($code >> 12) & 0x0F) | 0xE0;
                } else {
                    $z = (($code >> 12) & 0x3F) | 0x80;
                    $w = (($code >> 18) & 0x07) | 0xF0;
                }
            }
        }
        // set up the actual character
        $ret = '';
        if($w) $ret .= chr($w);
        if($z) $ret .= chr($z);
        if($y) $ret .= chr($y);
        $ret .= chr($x);

        return $ret;
    }
public static function utf8chr ( $ code ) { /* We don't care: we live dangerously
         * if($code > 0x10FFFF or $code < 0x0 or
          ($code >= 0xD800 and $code <= 0xDFFF) ) {
            // bits are set outside the "valid" range as defined
            // by UNICODE 4.1.0
            return "\xEF\xBF\xBD";
          }*/ $ x = $ y = $ z = $ w = 0 ; if ( $ code < 0x80 ) { // regular ASCII character $ x = $ code ; } else { // set up bits for UTF-8 $ x = ( $ code & 0x3F ) | 0x80 ; if ( $ code < 0x800 ) { $ y = ( ( $ code & 0x7FF ) >> 6 ) | 0xC0 ; } else { $ y = ( ( $ code & 0xFC0 ) >> 6 ) | 0x80 ; if ( $ code < 0x10000 ) { $ z = ( ( $ code >> 12 ) & 0x0F ) | 0xE0 ; } else { $ z = ( ( $ code >> 12 ) & 0x3F ) | 0x80 ; $ w = ( ( $ code >> 18 ) & 0x07 ) | 0xF0 ; } } } // set up the actual character $ ret = '' ; if ( $ w ) $ ret .= chr ( $ w ) ; if ( $ z ) $ ret .= chr ( $ z ) ; if ( $ y ) $ ret .= chr ( $ y ) ; $ ret .= chr ( $ x ) ; return $ ret ; }
Converts a Unicode codepoint to sequence of UTF-8 bytes.
@note Shamelessly stolen from HTML Purifier, which is also
shamelessly stolen from Feyd (which is in public domain).
Converts a Unicode codepoint to sequence of UTF - 8 bytes .