本文整理匯總了PHP中getid3_lib::BigEndian2String方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::BigEndian2String方法的具體用法?PHP getid3_lib::BigEndian2String怎麽用?PHP getid3_lib::BigEndian2String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類getid3_lib
的用法示例。
在下文中一共展示了getid3_lib::BigEndian2String方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: iconv_fallback_utf8_utf16be
static function iconv_fallback_utf8_utf16be($string, $bom = false)
{
$newcharstring = '';
if ($bom) {
$newcharstring .= "þÿ";
}
$offset = 0;
$stringlength = strlen($string);
while ($offset < $stringlength) {
if ((ord($string[$offset]) | 0x7) == 0xf7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = (ord($string[$offset + 0]) & 0x7) << 18 & (ord($string[$offset + 1]) & 0x3f) << 12 & (ord($string[$offset + 2]) & 0x3f) << 6 & (ord($string[$offset + 3]) & 0x3f);
$offset += 4;
} elseif ((ord($string[$offset]) | 0xf) == 0xef) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = (ord($string[$offset + 0]) & 0xf) << 12 & (ord($string[$offset + 1]) & 0x3f) << 6 & (ord($string[$offset + 2]) & 0x3f);
$offset += 3;
} elseif ((ord($string[$offset]) | 0x1f) == 0xdf) {
// 110bbbbb 10bbbbbb
$charval = (ord($string[$offset + 0]) & 0x1f) << 6 & (ord($string[$offset + 1]) & 0x3f);
$offset += 2;
} elseif ((ord($string[$offset]) | 0x7f) == 0x7f) {
// 0bbbbbbb
$charval = ord($string[$offset]);
$offset += 1;
} else {
// error? throw some kind of warning here?
$charval = false;
$offset += 1;
}
if ($charval !== false) {
$newcharstring .= $charval < 65536 ? getid3_lib::BigEndian2String($charval, 2) : "" . '?';
}
}
return $newcharstring;
}
示例2: GenerateCONTchunk
public function GenerateCONTchunk()
{
foreach ($this->tag_data as $key => $value) {
// limit each value to 0xFFFF bytes
$this->tag_data[$key] = substr($value, 0, 65535);
}
$CONTchunk = "";
// object version
$CONTchunk .= getid3_lib::BigEndian2String(!empty($this->tag_data['title']) ? strlen($this->tag_data['title']) : 0, 2);
$CONTchunk .= !empty($this->tag_data['title']) ? strlen($this->tag_data['title']) : '';
$CONTchunk .= getid3_lib::BigEndian2String(!empty($this->tag_data['artist']) ? strlen($this->tag_data['artist']) : 0, 2);
$CONTchunk .= !empty($this->tag_data['artist']) ? strlen($this->tag_data['artist']) : '';
$CONTchunk .= getid3_lib::BigEndian2String(!empty($this->tag_data['copyright']) ? strlen($this->tag_data['copyright']) : 0, 2);
$CONTchunk .= !empty($this->tag_data['copyright']) ? strlen($this->tag_data['copyright']) : '';
$CONTchunk .= getid3_lib::BigEndian2String(!empty($this->tag_data['comment']) ? strlen($this->tag_data['comment']) : 0, 2);
$CONTchunk .= !empty($this->tag_data['comment']) ? strlen($this->tag_data['comment']) : '';
if ($this->paddedlength > strlen($CONTchunk) + 8) {
$CONTchunk .= str_repeat("", $this->paddedlength - strlen($CONTchunk) - 8);
}
$CONTchunk = 'CONT' . getid3_lib::BigEndian2String(strlen($CONTchunk) + 8, 4) . $CONTchunk;
// CONT chunk identifier + chunk length
return $CONTchunk;
}
示例3: Float2String
function Float2String($floatvalue, $bits)
{
// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
switch ($bits) {
case 32:
$exponentbits = 8;
$fractionbits = 23;
break;
case 64:
$exponentbits = 11;
$fractionbits = 52;
break;
default:
return false;
break;
}
if ($floatvalue >= 0) {
$signbit = '0';
} else {
$signbit = '1';
}
$normalizedbinary = getid3_lib::NormalizeBinaryPoint(getid3_lib::Float2BinaryDecimal($floatvalue), $fractionbits);
$biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent'];
// (127 or 1023) +/- exponent
$exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT);
$fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT);
return getid3_lib::BigEndian2String(getid3_lib::Bin2Dec($signbit . $exponentbitstring . $fractionbitstring), $bits % 8, false);
}
示例4: iconv_fallback_utf8_utf16be
function iconv_fallback_utf8_utf16be($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFE\xFF";
}
$offset = 0;
$stringlength = strlen($string);
while ($offset < $stringlength) {
if ((ord($string{$offset}) | 0x07) == 0xF7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
((ord($string{($offset + 1)}) & 0x3F) << 12) &
((ord($string{($offset + 2)}) & 0x3F) << 6) &
(ord($string{($offset + 3)}) & 0x3F);
$offset += 4;
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
((ord($string{($offset + 1)}) & 0x3F) << 6) &
(ord($string{($offset + 2)}) & 0x3F);
$offset += 3;
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
// 110bbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
(ord($string{($offset + 1)}) & 0x3F);
$offset += 2;
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
// 0bbbbbbb
$charval = ord($string{$offset});
$offset += 1;
} else {
// error? throw some kind of warning here?
$charval = false;
$offset += 1;
}
if ($charval !== false) {
$newcharstring .= (($charval < 65536) ? getid3_lib::BigEndian2String($charval, 2) : "\x00".'?');
}
}
return $newcharstring;
}
示例5: GenerateID3v2Tag
function GenerateID3v2Tag($noerrorsonly = true)
{
$this->ID3v2FrameIsAllowed(null, '');
// clear static array in case this isn't the first call to $this->GenerateID3v2Tag()
$tagstring = '';
if (is_array($this->tag_data)) {
foreach ($this->tag_data as $frame_name => $frame_rawinputdata) {
foreach ($frame_rawinputdata as $irrelevantindex => $source_data_array) {
if (getid3_id3v2::IsValidID3v2FrameName($frame_name, $this->majorversion)) {
unset($frame_length);
unset($frame_flags);
$frame_data = false;
if ($this->ID3v2FrameIsAllowed($frame_name, $source_data_array)) {
if ($frame_data = $this->GenerateID3v2FrameData($frame_name, $source_data_array)) {
$FrameUnsynchronisation = false;
if ($this->majorversion >= 4) {
// frame-level unsynchronisation
$unsynchdata = $frame_data;
if ($this->id3v2_use_unsynchronisation) {
$unsynchdata = $this->Unsynchronise($frame_data);
}
if (strlen($unsynchdata) != strlen($frame_data)) {
// unsynchronisation needed
$FrameUnsynchronisation = true;
$frame_data = $unsynchdata;
if (isset($TagUnsynchronisation) && $TagUnsynchronisation === false) {
// only set to true if ALL frames are unsynchronised
} else {
$TagUnsynchronisation = true;
}
} else {
if (isset($TagUnsynchronisation)) {
$TagUnsynchronisation = false;
}
}
unset($unsynchdata);
$frame_length = getid3_lib::BigEndian2String(strlen($frame_data), 4, true);
} else {
$frame_length = getid3_lib::BigEndian2String(strlen($frame_data), 4, false);
}
$frame_flags = $this->GenerateID3v2FrameFlags($this->ID3v2FrameFlagsLookupTagAlter($frame_name), $this->ID3v2FrameFlagsLookupFileAlter($frame_name), false, false, false, false, $FrameUnsynchronisation, false);
}
} else {
$this->errors[] = 'Frame "' . $frame_name . '" is NOT allowed';
}
if ($frame_data === false) {
$this->errors[] = '$this->GenerateID3v2FrameData() failed for "' . $frame_name . '"';
if ($noerrorsonly) {
return false;
} else {
unset($frame_name);
}
}
} else {
// ignore any invalid frame names, including 'title', 'header', etc
$this->warnings[] = 'Ignoring invalid ID3v2 frame type: "' . $frame_name . '"';
unset($frame_name);
unset($frame_length);
unset($frame_flags);
unset($frame_data);
}
if (isset($frame_name) && isset($frame_length) && isset($frame_flags) && isset($frame_data)) {
$tagstring .= $frame_name . $frame_length . $frame_flags . $frame_data;
}
}
}
if (!isset($TagUnsynchronisation)) {
$TagUnsynchronisation = false;
}
if ($this->majorversion <= 3 && $this->id3v2_use_unsynchronisation) {
// tag-level unsynchronisation
$unsynchdata = $this->Unsynchronise($tagstring);
if (strlen($unsynchdata) != strlen($tagstring)) {
// unsynchronisation needed
$TagUnsynchronisation = true;
$tagstring = $unsynchdata;
}
}
while ($this->paddedlength < strlen($tagstring) + getid3_id3v2::ID3v2HeaderLength($this->majorversion)) {
$this->paddedlength += 1024;
}
$footer = false;
// ID3v2 footers not yet supported in getID3()
if (!$footer && $this->paddedlength > strlen($tagstring) + getid3_id3v2::ID3v2HeaderLength($this->majorversion)) {
// pad up to $paddedlength bytes if unpadded tag is shorter than $paddedlength
// "Furthermore it MUST NOT have any padding when a tag footer is added to the tag."
$tagstring .= @str_repeat("", $this->paddedlength - strlen($tagstring) - getid3_id3v2::ID3v2HeaderLength($this->majorversion));
}
if ($this->id3v2_use_unsynchronisation && substr($tagstring, strlen($tagstring) - 1, 1) == "ÿ") {
// special unsynchronisation case:
// if last byte == $FF then appended a $00
$TagUnsynchronisation = true;
$tagstring .= "";
}
$tagheader = 'ID3';
$tagheader .= chr($this->majorversion);
$tagheader .= chr($this->minorversion);
$tagheader .= $this->GenerateID3v2TagFlags(array('unsynchronisation' => $TagUnsynchronisation));
$tagheader .= getid3_lib::BigEndian2String(strlen($tagstring), 4, true);
return $tagheader . $tagstring;
//.........這裏部分代碼省略.........
示例6: generate_frame_data
protected function generate_frame_data($frame_name, $source_data_array)
{
$frame_data = '';
switch ($frame_name) {
case 'UFID':
// 4.1 UFID Unique file identifier
// Owner identifier <text string> $00
// Identifier <up to 64 bytes binary data>
if (strlen($source_data_array['data']) > 64) {
throw new getid3_exception('Identifier not allowed to be longer than 64 bytes in ' . $frame_name . ' (supplied data was ' . strlen($source_data_array['data']) . ' bytes long)');
}
$frame_data .= str_replace("", '', $source_data_array['ownerid']) . "";
$frame_data .= substr($source_data_array['data'], 0, 64);
// max 64 bytes - truncate anything longer
break;
case 'TXXX':
// 4.2.2 TXXX User defined text information frame
// Text encoding $xx
// Description <text string according to encoding> $00 (00)
// Value <text string according to encoding>
$frame_data .= chr(3);
// UTF-8 encoding
$frame_data .= $source_data_array['description'] . "";
$frame_data .= $source_data_array['data'];
break;
case 'WXXX':
// 4.3.2 WXXX User defined URL link frame
// Text encoding $xx
// Description <text string according to encoding> $00 (00)
// URL <text string>
if (!isset($source_data_array['data']) || !$this->valid_url($source_data_array['data'], false, false)) {
throw new getid3_exception('Invalid URL in ' . $frame_name . ' (' . $source_data_array['data'] . ')');
}
$frame_data .= chr(3);
// UTF-8 encoding
$frame_data .= $source_data_array['description'] . "";
$frame_data .= $source_data_array['data'];
break;
case 'IPLS':
// 4.4 IPLS Involved people list (ID3v2.3 only)
// Text encoding $xx
// People list strings <textstrings>
$frame_data .= chr(3);
// UTF-8 encoding
$frame_data .= $source_data_array['data'];
break;
case 'MCDI':
// 4.4 MCDI Music CD identifier
// CD TOC <binary data>
$frame_data .= $source_data_array['data'];
break;
case 'ETCO':
// 4.5 ETCO Event timing codes
// Time stamp format $xx
// Where time stamp format is:
// $01 (32-bit value) MPEG frames from beginning of file
// $02 (32-bit value) milliseconds from beginning of file
// Followed by a list of key events in the following format:
// Type of event $xx
// Time stamp $xx (xx ...)
// The 'Time stamp' is set to zero if directly at the beginning of the sound
// or after the previous event. All events MUST be sorted in chronological order.
if ($source_data_array['timestampformat'] > 2 || $source_data_array['timestampformat'] < 1) {
throw new getid3_exception('Invalid Time Stamp Format byte in ' . $frame_name . ' (' . $source_data_array['timestampformat'] . ')');
}
$frame_data .= chr($source_data_array['timestampformat']);
foreach ($source_data_array as $key => $val) {
if (!$this->ID3v2IsValidETCOevent($val['typeid'])) {
throw new getid3_exception('Invalid Event Type byte in ' . $frame_name . ' (' . $val['typeid'] . ')');
}
if ($key != 'timestampformat' && $key != 'flags') {
if ($val['timestamp'] > 0 && $previousETCOtimestamp >= $val['timestamp']) {
// The 'Time stamp' is set to zero if directly at the beginning of the sound
// or after the previous event. All events MUST be sorted in chronological order.
throw new getid3_exception('Out-of-order timestamp in ' . $frame_name . ' (' . $val['timestamp'] . ') for Event Type (' . $val['typeid'] . ')');
}
$frame_data .= chr($val['typeid']);
$frame_data .= getid3_lib::BigEndian2String($val['timestamp'], 4, false);
}
}
break;
case 'MLLT':
// 4.6 MLLT MPEG location lookup table
// MPEG frames between reference $xx xx
// Bytes between reference $xx xx xx
// Milliseconds between reference $xx xx xx
// Bits for bytes deviation $xx
// Bits for milliseconds dev. $xx
// Then for every reference the following data is included;
// Deviation in bytes %xxx....
// Deviation in milliseconds %xxx....
if ($source_data_array['framesbetweenreferences'] > 0 && $source_data_array['framesbetweenreferences'] <= 65535) {
$frame_data .= getid3_lib::BigEndian2String($source_data_array['framesbetweenreferences'], 2, false);
} else {
throw new getid3_exception('Invalid MPEG Frames Between References in ' . $frame_name . ' (' . $source_data_array['framesbetweenreferences'] . ')');
}
if ($source_data_array['bytesbetweenreferences'] > 0 && $source_data_array['bytesbetweenreferences'] <= 16777215) {
$frame_data .= getid3_lib::BigEndian2String($source_data_array['bytesbetweenreferences'], 3, false);
} else {
throw new getid3_exception('Invalid bytes Between References in ' . $frame_name . ' (' . $source_data_array['bytesbetweenreferences'] . ')');
//.........這裏部分代碼省略.........