- /**
- * Convert a hex string representing a Unicode code point to that code point.
- * @param string $c
- * @return string|false
- */
- protected function unicodeChar( $c ) {
- $c = hexdec( $c );
- if ( $c <= 0x7F ) {
- return chr( $c );
- } elseif ( $c <= 0x7FF ) {
- return chr( 0xC0 | $c >> 6 ) . chr( 0x80 | $c & 0x3F );
- } elseif ( $c <= 0xFFFF ) {
- return chr( 0xE0 | $c >> 12 ) . chr( 0x80 | $c >> 6 & 0x3F ) .
- chr( 0x80 | $c & 0x3F );
- } elseif ( $c <= 0x10FFFF ) {
- return chr( 0xF0 | $c >> 18 ) . chr( 0x80 | $c >> 12 & 0x3F ) .
- chr( 0x80 | $c >> 6 & 0x3F ) .
- chr( 0x80 | $c & 0x3F );
- } else {
- return false;
- }
- }
-