eZ\Publish\Core\Persistence\TransformationProcessor\PcreCompiler::compileCharacter PHP Method

compileCharacter() protected method

Handles the two formats from the possible character definitions: - U+xxxx : Unicode value in hexadecimal - xx: Ascii value in hexadecimal
protected compileCharacter ( string $char ) : string
$char string
return string
    protected function compileCharacter($char)
    {
        switch (true) {
            case preg_match('(^U\\+[0-9a-fA-F]{4}$)', $char):
                return $this->converter->toUTF8Character(hexdec(substr($char, 2)));
            case preg_match('(^[0-9a-fA-F]{2}$)', $char):
                return chr(hexdec($char));
            default:
                throw new RuntimeException("Invalid character definition: {$char}");
        }
    }