public static function toUTF8Character($charCode)
    {
        switch ($charCode) {
            case 0:
                $char = chr(0);
                break;
            case !($charCode & 0xffffff80): // 7 bit
                $char = chr($charCode);
                break;
            case !($charCode & 0xfffff800): // 11 bit
                $char = (
                    chr(0xc0 | (($charCode >> 6) & 0x1f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            case !($charCode & 0xffff0000): // 16 bit
                $char = (
                    chr(0xe0 | (($charCode >> 12) & 0x0f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            case !($charCode & 0xffe00000): // 21 bit
                $char = (
                    chr(0xf0 | (($charCode >> 18) & 0x07)) .
                    chr(0x80 | (($charCode >> 12) & 0x3f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            case !($charCode & 0xfc000000): // 26 bit
                $char = (
                    chr(0xf8 | (($charCode >> 24) & 0x03)) .
                    chr(0x80 | (($charCode >> 18) & 0x3f)) .
                    chr(0x80 | (($charCode >> 12) & 0x3f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            default: // 31 bit
                $char = (
                    chr(0xfc | (($charCode >> 30) & 0x01)) .
                    chr(0x80 | (($charCode >> 24) & 0x3f)) .
                    chr(0x80 | (($charCode >> 18) & 0x3f)) .
                    chr(0x80 | (($charCode >> 12) & 0x3f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
        }

        return $char;
    }
public static function toUTF8Character($charCode)
    {
        switch ($charCode) {
            case 0:
                $char = chr(0);
                break;
            case !($charCode & 0xffffff80): // 7 bit
                $char = chr($charCode);
                break;
            case !($charCode & 0xfffff800): // 11 bit
                $char = (
                    chr(0xc0 | (($charCode >> 6) & 0x1f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            case !($charCode & 0xffff0000): // 16 bit
                $char = (
                    chr(0xe0 | (($charCode >> 12) & 0x0f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            case !($charCode & 0xffe00000): // 21 bit
                $char = (
                    chr(0xf0 | (($charCode >> 18) & 0x07)) .
                    chr(0x80 | (($charCode >> 12) & 0x3f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            case !($charCode & 0xfc000000): // 26 bit
                $char = (
                    chr(0xf8 | (($charCode >> 24) & 0x03)) .
                    chr(0x80 | (($charCode >> 18) & 0x3f)) .
                    chr(0x80 | (($charCode >> 12) & 0x3f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
                break;
            default: // 31 bit
                $char = (
                    chr(0xfc | (($charCode >> 30) & 0x01)) .
                    chr(0x80 | (($charCode >> 24) & 0x3f)) .
                    chr(0x80 | (($charCode >> 18) & 0x3f)) .
                    chr(0x80 | (($charCode >> 12) & 0x3f)) .
                    chr(0x80 | (($charCode >> 6) & 0x3f)) .
                    chr(0x80 | ($charCode & 0x3f))
                );
        }

        return $char;
    }
public static function toUTF8Character ( $ charCode ) { switch ( $ charCode ) { case 0 : $ char = chr ( 0 ) ; break ; case ! ( $ charCode & 0xffffff80 ) : // 7 bit $ char = chr ( $ charCode ) ; break ; case ! ( $ charCode & 0xfffff800 ) : // 11 bit $ char = ( chr ( 0xc0 | ( ( $ charCode >> 6 ) & 0x1f ) ) . chr ( 0x80 | ( $ charCode & 0x3f ) ) ) ; break ; case ! ( $ charCode & 0xffff0000 ) : // 16 bit $ char = ( chr ( 0xe0 | ( ( $ charCode >> 12 ) & 0x0f ) ) . chr ( 0x80 | ( ( $ charCode >> 6 ) & 0x3f ) ) . chr ( 0x80 | ( $ charCode & 0x3f ) ) ) ; break ; case ! ( $ charCode & 0xffe00000 ) : // 21 bit $ char = ( chr ( 0xf0 | ( ( $ charCode >> 18 ) & 0x07 ) ) . chr ( 0x80 | ( ( $ charCode >> 12 ) & 0x3f ) ) . chr ( 0x80 | ( ( $ charCode >> 6 ) & 0x3f ) ) . chr ( 0x80 | ( $ charCode & 0x3f ) ) ) ; break ; case ! ( $ charCode & 0xfc000000 ) : // 26 bit $ char = ( chr ( 0xf8 | ( ( $ charCode >> 24 ) & 0x03 ) ) . chr ( 0x80 | ( ( $ charCode >> 18 ) & 0x3f ) ) . chr ( 0x80 | ( ( $ charCode >> 12 ) & 0x3f ) ) . chr ( 0x80 | ( ( $ charCode >> 6 ) & 0x3f ) ) . chr ( 0x80 | ( $ charCode & 0x3f ) ) ) ; break ; default : // 31 bit $ char = ( chr ( 0xfc | ( ( $ charCode >> 30 ) & 0x01 ) ) . chr ( 0x80 | ( ( $ charCode >> 24 ) & 0x3f ) ) . chr ( 0x80 | ( ( $ charCode >> 18 ) & 0x3f ) ) . chr ( 0x80 | ( ( $ charCode >> 12 ) & 0x3f ) ) . chr ( 0x80 | ( ( $ charCode >> 6 ) & 0x3f ) ) . chr ( 0x80 | ( $ charCode & 0x3f ) ) ) ; } return $ char ; }
Convert character code to UTF-8 character.

@param int $charCode

@return string
Convert character code to UTF - 8 character .