getid3_lib::PrintHexBytes

Advertisement

Syntax Syntax

getid3_lib::PrintHexBytes( string $string, bool $hex = true, bool $spaces = true, string $htmlencoding = 'UTF-8' )

Parameters Parameters

$string

(Required)

$hex

(Optional)

Default value: true

$spaces

(Optional)

Default value: true

$htmlencoding

(Optional)

Default value: 'UTF-8'

Return Return

(string)

Source Source

File: wp-includes/ID3/getid3.lib.php

	public static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') {
		$returnstring = '';
		for ($i = 0; $i < strlen($string); $i++) {
			if ($hex) {
				$returnstring .= str_pad(dechex(ord($string[$i])), 2, '0', STR_PAD_LEFT);
			} else {
				$returnstring .= ' '.(preg_match("#[\x20-\x7E]#", $string[$i]) ? $string[$i] : '¤');
			}
			if ($spaces) {
				$returnstring .= ' ';
			}
		}
		if (!empty($htmlencoding)) {
			if ($htmlencoding === true) {
				$htmlencoding = 'UTF-8'; // prior to getID3 v1.9.0 the function's 4th parameter was boolean
			}
			$returnstring = htmlentities($returnstring, ENT_QUOTES, $htmlencoding);
		}
		return $returnstring;
	}

Advertisement

Advertisement

Leave a Reply