You are here

public static function ConversionHelper::hex2string in Lightweight Directory Access Protocol (LDAP) 8.4

Converts all hex expressions ("\HEX") to their original characters.

Parameters

string $input: String to convert.

Return value

string Converted string.

1 call to ConversionHelper::hex2string()
ConversionHelper::unescapeDnValue in ldap_servers/src/Helper/ConversionHelper.php
Undoes the conversion done by escape_dn_value().

File

ldap_servers/src/Helper/ConversionHelper.php, line 50

Class

ConversionHelper
Conversion helper to escape values correctly for LDAP filters.

Namespace

Drupal\ldap_servers\Helper

Code

public static function hex2string(string $input) : string {
  return preg_replace_callback("/\\\\([0-9A-Fa-f]{2})/", static function (array $matches) {
    $subject = str_replace('\\', '', $matches[0]);
    return pack("H*", $subject);
  }, $input);
}