src/BaconStringUtils/UniDecoder.php
public function decode($string)
    {
        $return = '';

        foreach (preg_split('()u', $string, -1, PREG_SPLIT_NO_EMPTY) as $char) {
            $codepoint = $this->uniOrd($char);

            if ($codepoint < 0x80) {
                // Basic ASCII
                $return .= chr($codepoint);
                continue;
            }

            if ($codepoint > 0xeffff) {
                // Characters in Private Use Area and above are ignored
                continue;
            }

            $section  = $codepoint >> 8;  // Chop off the last two hex digits
            $position = $codepoint % 256; // Last two hex digits

            if (!isset(self::$tables[$section])) {
                self::$tables[$section] = @include sprintf('%s/UniDecoder/x%03x.php', __DIR__, $section);
            }

            if (isset(self::$tables[$section][$position])) {
                $return .= self::$tables[$section][$position];
            }
        }

        return $return;
    }
public function decode($string)
    {
        $return = '';

        foreach (preg_split('()u', $string, -1, PREG_SPLIT_NO_EMPTY) as $char) {
            $codepoint = $this->uniOrd($char);

            if ($codepoint < 0x80) {
                // Basic ASCII
                $return .= chr($codepoint);
                continue;
            }

            if ($codepoint > 0xeffff) {
                // Characters in Private Use Area and above are ignored
                continue;
            }

            $section  = $codepoint >> 8;  // Chop off the last two hex digits
            $position = $codepoint % 256; // Last two hex digits

            if (!isset(self::$tables[$section])) {
                self::$tables[$section] = @include sprintf('%s/UniDecoder/x%03x.php', __DIR__, $section);
            }

            if (isset(self::$tables[$section][$position])) {
                $return .= self::$tables[$section][$position];
            }
        }

        return $return;
    }
public function decode ( $ string ) { $ return = '' ; foreach ( preg_split ( '()u' , $ string , - 1 , PREG_SPLIT_NO_EMPTY ) as $ char ) { $ codepoint = $ this -> uniOrd ( $ char ) ; if ( $ codepoint < 0x80 ) { // Basic ASCII $ return .= chr ( $ codepoint ) ; continue ; } if ( $ codepoint > 0xeffff ) { // Characters in Private Use Area and above are ignored continue ; } $ section = $ codepoint >> 8 ; // Chop off the last two hex digits $ position = $ codepoint % 256 ; // Last two hex digits if ( ! isset ( self :: $ tables [ $ section ] ) ) { self :: $ tables [ $ section ] = @ include sprintf ( '%s/UniDecoder/x%03x.php' , __DIR__ , $ section ) ; } if ( isset ( self :: $ tables [ $ section ] [ $ position ] ) ) { $ return .= self :: $ tables [ $ section ] [ $ position ] ; } } return $ return ; }
Decodes an UTF-8 encoded unicode string to ASCII.

@param  string $string
@return string
Decodes an UTF - 8 encoded unicode string to ASCII .