decode_uhex ( $s )

Decodes \uXXXX entities into their real unicode character equivalents.

Access

public

Parameters

Parameter

Type

Required

Description

$s

string

Required

The string to decode.

Returns

Type

Description

string

The decoded string.

Source

Method defined in utilities/utilities.class.php | Toggle source view (16 lines) | View on GitHub

public function decode_uhex($s)
{
    preg_match_all('/\\\u([0-9a-f]{4})/i', $s, $matches);
    $matches = $matches[count($matches) - 1];
    $map = array();

    foreach ($matches as $match)
    {
        if (!isset($map[$match]))
        {
            $map['\u' . $match] = html_entity_decode('&#' . hexdec($match) . ';', ENT_NOQUOTES, 'UTF-8');
        }
    }

    return str_replace(array_keys($map), $map, $s);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback