You are here

public static function FeedsJSONPathParser::doFourByteReplace in Feeds JSONPath Parser 7

Callback for FeedsJSONPathParser::convertFourBytes().

Parameters

array $matches: The regular expression matches.

Return value

string A four byte unicode character converted to its HTML representation.

File

./FeedsJSONPathParser.inc, line 509
Contains FeedsJSONPathParser.

Class

FeedsJSONPathParser
Parses JSON using JSONPath.

Code

public static function doFourByteReplace(array $matches) {
  $char = $matches[0];

  // Calculate the codepoint of the character.
  $codepoint = ord($char[0]) - 0xf0 << 18;
  $codepoint += ord($char[1]) - 0x80 << 12;
  $codepoint += ord($char[2]) - 0x80 << 6;
  $codepoint += ord($char[3]) - 0x80;
  return '&#' . $codepoint . ';';
}