Skip to content

Commit

Permalink
Function convert_hex_string() added. Issue #32.
Browse files Browse the repository at this point in the history
  • Loading branch information
martignoni committed Jul 13, 2018
1 parent a063a7e commit 74b768f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions classes/local/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,17 @@ public static function get_wireless_interface_name() {
return explode('/', array_keys(iterator_to_array($iter))[0])[4];
}

/**
* Convert string with hexadecimal code to unicode string.
* See https://stackoverflow.com/a/12083180.
*
* @param string $string to convert
* @return string converted
*/
public static function convert_hex_string($string) {
return preg_replace_callback('#\\\\x([[:xdigit:]]{2})#ism', function($matches) {
return chr(hexdec($matches[1]));
}, $string);
}

}

0 comments on commit 74b768f

Please sign in to comment.