Fix encoding and one byte field issue

git-svn-id: http://php-reader.googlecode.com/svn/trunk@12 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2008-03-17 12:54:34 +00:00
parent 165d162582
commit 3914cfdacc
16 changed files with 170 additions and 175 deletions

View File

@@ -47,16 +47,16 @@
interface ID3_Encoding interface ID3_Encoding
{ {
/** The ISO-8859-1 encoding. */ /** The ISO-8859-1 encoding. */
const ISO88591 = 0x00; const ISO88591 = 0;
/** The UTF-16 Unicode encoding with BOM. */ /** The UTF-16 Unicode encoding with BOM. */
const UTF16 = 0x01; const UTF16 = 1;
/** The UTF-16BE Unicode encoding without BOM. */ /** The UTF-16BE Unicode encoding without BOM. */
const UTF16BE = 0x02; const UTF16BE = 2;
/** The UTF-8 Unicode encoding. */ /** The UTF-8 Unicode encoding. */
const UTF8 = 0x03; const UTF8 = 3;
/** /**
* Returns the text encoding. * Returns the text encoding.

View File

@@ -67,27 +67,14 @@ final class ID3_Frame_APIC extends ID3_Frame
* @var Array * @var Array
*/ */
public static $types = array public static $types = array
(0x00 => "Other", ("Other", "32x32 pixels file icon (PNG only)", "Other file icon",
0x01 => "32x32 pixels file icon (PNG only)", "Cover (front)", "Cover (back)", "Leaflet page",
0x02 => "Other file icon", "Media (e.g. label side of CD)", "Lead artist/lead performer/soloist",
0x03 => "Cover (front)", "Artist/performer", "Conductor", "Band/Orchestra", "Composer",
0x04 => "Cover (back)", "Lyricist/text writer", "Recording Location", "During recording",
0x05 => "Leaflet page", "During performance", "Movie/video screen capture",
0x06 => "Media (e.g. label side of CD)", "A bright coloured fish", "Illustration", "Band/artist logotype",
0x07 => "Lead artist/lead performer/soloist", "Publisher/Studio logotype");
0x08 => "Artist/performer",
0x09 => "Conductor",
0x0A => "Band/Orchestra",
0x0B => "Composer",
0x0C => "Lyricist/text writer",
0x0D => "Recording Location",
0x0E => "During recording",
0x0F => "During performance",
0x10 => "Movie/video screen capture",
0x11 => "A bright coloured fish",
0x12 => "Illustration",
0x13 => "Band/artist logotype",
0x14 => "Publisher/Studio logotype");
/** @var integer */ /** @var integer */
private $_encoding; private $_encoding;
@@ -113,22 +100,27 @@ final class ID3_Frame_APIC extends ID3_Frame
$this->_encoding = substr($this->_data, 0, 1); $this->_encoding = substr($this->_data, 0, 1);
$this->_mimeType = substr $this->_mimeType = substr
($this->_data, 1, ($pos = strpos($this->_data, "\0", 1)) - 1); ($this->_data, 1, ($pos = strpos($this->_data, "\0", 1)) - 1);
$this->_pictureType = substr($this->_data, $pos++, 1); $this->_pictureType = ord($this->_data{$pos++});
$this->_data = substr($this->_data, $pos);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16: case self::UTF16:
list ($this->_description, $this->_data) = $bom = substr($this->_data, 0, 2);
preg_split("/\\x00\\x00/", substr($this->_data, $pos), 2); $this->_data = substr($this->_data, 2);
$this->_description = Transform::getString16LE($this->_description); if ($bom == 0xfffe) {
break; list ($this->_description, $this->_data) =
preg_split("/\\x00\\x00/", $this->_data, 2);
$this->_description = Transform::getString16LE($this->_description);
break;
}
case self::UTF16BE: case self::UTF16BE:
list ($this->_description, $this->_data) = list ($this->_description, $this->_data) =
preg_split("/\\x00\\x00/", substr($this->_data, $pos), 2); preg_split("/\\x00\\x00/", $this->_data, 2);
$this->_description = Transform::getString16BE($this->_description); $this->_description = Transform::getString16BE($this->_description);
break; break;
default: default:
list ($this->_description, $this->_data) = list ($this->_description, $this->_data) =
preg_split("/\\x00/", substr($this->_data, $pos), 2); preg_split("/\\x00/", $this->_data, 2);
$this->_description = Transform::getString8($this->_description);
} }
} }

View File

@@ -66,19 +66,23 @@ abstract class ID3_Frame_AbstractText extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_encoding = substr($this->_data, 0, 1); $this->_encoding = ord($this->_data{0});
$this->_data = substr($this->_data, 1);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16: case self::UTF16:
$this->_data = Transform::getString16LE(substr($this->_data, 1)); $bom = substr($this->_data, 0, 2);
$this->_text = preg_split("/\\x00\\x00/", $this->_data); $this->_data = substr($this->_data, 2);
break; if ($bom == 0xfffe) {
$this->_text =
preg_split("/\\x00\\x00/", Transform::getString16LE($this->_data));
break;
}
case self::UTF16BE: case self::UTF16BE:
$this->_data = Transform::getString16BE(substr($this->_data, 1)); $this->_text =
$this->_text = preg_split("/\\x00\\x00/", $this->_data); preg_split("/\\x00\\x00/", Transform::getString16BE($this->_data));
break; break;
default: default:
$this->_data = Transform::getString8(substr($this->_data, 1)); $this->_text = preg_split("/\\x00/", Transform::getString8($this->_data));
$this->_text = preg_split("/\\x00/", $this->_data);
} }
} }

View File

@@ -78,25 +78,30 @@ final class ID3_Frame_COMM extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_encoding = substr($this->_data, 0, 1); $this->_encoding = ord($this->_data{0});
$this->_language = substr($this->_data, 1, 3); $this->_language = substr($this->_data, 1, 3);
$this->_data = substr($this->_data, 4);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16: case self::UTF16:
list ($this->_description, $this->_text) = $bom = substr($this->_data, 0, 2);
preg_split("/\\x00\\x00/", substr($this->_data, 4), 2); $this->_data = substr($this->_data, 2);
$this->_description = Transform::getString16LE($this->_description); if ($bom == 0xfffe) {
$this->_text = Transform::getString16LE($this->_text); list ($this->_description, $this->_text) =
break; preg_split("/\\x00\\x00/", $this->_data, 2);
$this->_description = Transform::getString16LE($this->_description);
$this->_text = Transform::getString16LE($this->_text);
break;
}
case self::UTF16BE: case self::UTF16BE:
list ($this->_description, $this->_text) = list ($this->_description, $this->_text) =
preg_split("/\\x00\\x00/", substr($this->_data, 4), 2); preg_split("/\\x00\\x00/", $this->_data, 2);
$this->_description = Transform::getString16BE($this->_description); $this->_description = Transform::getString16BE($this->_description);
$this->_text = Transform::getString16BE($this->_text); $this->_text = Transform::getString16BE($this->_text);
break; break;
default: default:
list ($this->_description, $this->_text) = list ($this->_description, $this->_text) =
preg_split("/\\x00/", substr($this->_data, 4), 2); preg_split("/\\x00/", $this->_data, 2);
$this->_description = Transform::getString8($this->_description); $this->_description = Transform::getString8($this->_description);
$this->_text = Transform::getString8($this->_text); $this->_text = Transform::getString8($this->_text);
} }

View File

@@ -63,15 +63,10 @@ final class ID3_Frame_COMR extends ID3_Frame
* @var Array * @var Array
*/ */
public static $types = array public static $types = array
(0x00 => "Other", ("Other", "Standard CD album with other songs", "Compressed audio on CD",
0x01 => "Standard CD album with other songs", "File over the Internet", "Stream over the Internet", "As note sheets",
0x02 => "Compressed audio on CD", "As note sheets in a book with other sheets", "Music on other media",
0x03 => "File over the Internet", "Non-musical merchandise");
0x04 => "Stream over the Internet",
0x05 => "As note sheets",
0x06 => "As note sheets in a book with other sheets",
0x07 => "Music on other media",
0x08 => "Non-musical merchandise");
/** @var integer */ /** @var integer */
private $_encoding; private $_encoding;
@@ -109,7 +104,7 @@ final class ID3_Frame_COMR extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_encoding = substr($this->_data, 0, 1); $this->_encoding = ord($this->_data{0});
list($pricing, $this->_data) = list($pricing, $this->_data) =
preg_split("/\\x00/", substr($this->_data, 1), 2); preg_split("/\\x00/", substr($this->_data, 1), 2);
$this->_currency = substr($pricing, 0, 3); $this->_currency = substr($pricing, 0, 3);
@@ -117,24 +112,29 @@ final class ID3_Frame_COMR extends ID3_Frame
$this->_date = substr($this->_data, 0, 8); $this->_date = substr($this->_data, 0, 8);
list($this->_contact, $this->_data) = list($this->_contact, $this->_data) =
preg_split("/\\x00/", substr($this->_data, 8), 2); preg_split("/\\x00/", substr($this->_data, 8), 2);
$this->_delivery = substr($this->_data, 0, 1); $this->_delivery = ord($this->_data{0});
$this->_data = substr($this->_data, 1);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16: case self::UTF16:
list ($this->_seller, $this->_description, $this->_data) = $bom = substr($this->_data, 0, 2);
preg_split("/\\x00\\x00/", substr($this->_data, 1), 3); $this->_data = substr($this->_data, 2);
$this->_seller = Transform::getString16LE($this->_seller); if ($bom == 0xfffe) {
$this->_description = Transform::getString16LE($this->_description); list ($this->_seller, $this->_description, $this->_data) =
break; preg_split("/\\x00\\x00/", $this->_data, 3);
$this->_seller = Transform::getString16LE($this->_seller);
$this->_description = Transform::getString16LE($this->_description);
break;
}
case self::UTF16BE: case self::UTF16BE:
list ($this->_seller, $this->_description, $this->_data) = list ($this->_seller, $this->_description, $this->_data) =
preg_split("/\\x00\\x00/", substr($this->_data, 1), 3); preg_split("/\\x00\\x00/", $this->_data, 3);
$this->_seller = Transform::getString16BE($this->_seller); $this->_seller = Transform::getString16BE($this->_seller);
$this->_description = Transform::getString16BE($this->_description); $this->_description = Transform::getString16BE($this->_description);
break; break;
default: default:
list ($this->_seller, $this->_description, $this->_data) = list ($this->_seller, $this->_description, $this->_data) =
preg_split("/\\x00/", substr($this->_data, 1), 3); preg_split("/\\x00/", $this->_data, 3);
$this->_seller = Transform::getString8($this->_seller); $this->_seller = Transform::getString8($this->_seller);
$this->_description = Transform::getString8($this->_description); $this->_description = Transform::getString8($this->_description);
} }

View File

@@ -68,46 +68,19 @@ final class ID3_Frame_ETCO extends ID3_Frame
* @var Array * @var Array
*/ */
public static $types = array public static $types = array
(0x00 => "Padding", ("Padding", "End of initial silence", "Intro start", "Main part start",
0x01 => "End of initial silence", "Outro start", "Outro end", "Verse start","Refrain start",
0x02 => "Intro start", "Interlude start", "Theme start", "Variation start", "Key change",
0x03 => "Main part start", "Time change", "Momentary unwanted noise", "Sustained noise",
0x04 => "Outro start", "Sustained noise end", "Intro end", "Main part end", "Verse end",
0x05 => "Outro end", "Refrain end", "Theme end", "Profanity", "Profanity end",
0x06 => "Verse start",
0x07 => "Refrain start", 0xe0 => "User event", "User event", "User event", "User event",
0x08 => "Interlude start", "User event", "User event", "User event", "User event", "User event",
0x09 => "Theme start", "User event", "User event", "User event", "User event", "User event",
0x0a => "Variation start",
0x0b => "Key change", 0xfd => "Audio end (start of silence)", "Audio file ends",
0x0c => "Time change", "One more byte of events follows");
0x0d => "Momentary unwanted noise",
0x0e => "Sustained noise",
0x0f => "Sustained noise end",
0x10 => "Intro end",
0x11 => "Main part end",
0x12 => "Verse end",
0x13 => "Refrain end",
0x14 => "Theme end",
0x15 => "Profanity",
0x16 => "Profanity end",
0xe0 => "User event",
0xe1 => "User event",
0xe2 => "User event",
0xe3 => "User event",
0xe4 => "User event",
0xe5 => "User event",
0xe6 => "User event",
0xe7 => "User event",
0xea => "User event",
0xeb => "User event",
0xec => "User event",
0xed => "User event",
0xee => "User event",
0xef => "User event",
0xfd => "Audio end (start of silence)",
0xfe => "Audio file ends",
0xff => "One more byte of events follows");
/** @var integer */ /** @var integer */
private $_format; private $_format;
@@ -124,11 +97,11 @@ final class ID3_Frame_ETCO extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_format = substr($this->_data, 0, 1); $this->_format = ord($this->_data{0});
for ($i = 1; $i < $this->getSize(); $i += 5) { for ($i = 1; $i < $this->getSize(); $i += 5) {
$this->_events[Transform::getInt32BE(substr($this->_data, $i + 1, 4))] = $this->_events[Transform::getInt32BE(substr($this->_data, $i + 1, 4))] =
$data = substr($this->_data, $i, 1); $data = $this->_data{$i};
if ($data == 0xff) if ($data == 0xff)
break; break;
} }

View File

@@ -73,25 +73,31 @@ final class ID3_Frame_GEOB extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_encoding = substr($this->_data, 0, 1); $this->_encoding = ord($this->_data{0});
$this->_mimeType = substr $this->_mimeType = substr
($this->_data, 1, ($pos = strpos($this->_data, "\0", 1)) - 1); ($this->_data, 1, ($pos = strpos($this->_data, "\0", 1)) - 1);
$this->_data = substr($this->_data, $pos);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16: case self::UTF16:
list ($this->_filename, $this->_description, $this->_data) = $bom = substr($this->_data, 0, 2);
preg_split("/\\x00\\x00/", substr($this->_data, $pos), 3); $this->_data = substr($this->_data, 2);
$this->_filename = Transform::getString16LE($this->_filename); if ($bom == 0xfffe) {
$this->_description = Transform::getString16LE($this->_description); list ($this->_filename, $this->_description, $this->_data) =
break; preg_split("/\\x00\\x00/", $this->_data, 3);
$this->_filename = Transform::getString16LE($this->_filename);
$this->_description = Transform::getString16LE($this->_description);
break;
}
case self::UTF16BE: case self::UTF16BE:
list ($this->_filename, $this->_description, $this->_data) = list ($this->_filename, $this->_description, $this->_data) =
preg_split("/\\x00\\x00/", substr($this->_data, $pos), 3); preg_split("/\\x00\\x00/", $this->_data, 3);
$this->_filename = Transform::getString16BE($this->_filename); $this->_filename = Transform::getString16BE($this->_filename);
$this->_description = Transform::getString16BE($this->_description); $this->_description = Transform::getString16BE($this->_description);
break; break;
default: default:
list ($this->_filename, $this->_description, $this->_data) = list ($this->_filename, $this->_description, $this->_data) =
preg_split("/\\x00/", substr($this->_data, $pos), 3); preg_split("/\\x00/", $this->_data, 3);
$this->_filename = Transform::getString8($this->_filename); $this->_filename = Transform::getString8($this->_filename);
$this->_description = Transform::getString8($this->_description); $this->_description = Transform::getString8($this->_description);
} }

View File

@@ -35,9 +35,6 @@
/**#@+ @ignore */ /**#@+ @ignore */
require_once("ID3/Frame.php"); require_once("ID3/Frame.php");
require_once("ID3/Encoding.php");
require_once("ID3/Language.php");
require_once("ID3/Timing.php");
/**#@-*/ /**#@-*/
/** /**

View File

@@ -79,21 +79,26 @@ final class ID3_Frame_OWNE extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_encoding = substr($this->_data, 0, 1); $this->_encoding = ord($this->_data{0});
list($tmp1, $tmp2) = preg_split("/\\x00/", substr($this->_data, 1), 2); list($tmp, $this->_data) = preg_split("/\\x00/", substr($this->_data, 1), 2);
$this->_currency = substr($tmp1, 0, 3); $this->_currency = substr($tmp, 0, 3);
$this->_price = substr($tmp1, 3); $this->_price = substr($tmp, 3);
$this->_date = substr($tmp2, 0, 8); $this->_date = substr($this->_data, 0, 8);
$this->_data = substr($this->_data, 8);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16: case self::UTF16:
$this->_seller = Transform::getString16LE(substr($tmp2, 8)); $bom = substr($this->_data, 0, 2);
break; $this->_data = substr($this->_data, 2);
if ($bom == 0xfffe) {
$this->_seller = Transform::getString16LE($this->_data);
break;
}
case self::UTF16BE: case self::UTF16BE:
$this->_seller = Transform::getString16BE(substr($tmp2, 8)); $this->_seller = Transform::getString16BE($this->_data);
break; break;
default: default:
$this->_seller = Transform::getString8(substr($tmp2, 8)); $this->_seller = Transform::getString8($this->_data);
} }
} }

View File

@@ -69,7 +69,7 @@ final class ID3_Frame_POSS extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_format = substr($this->_data, 0, 1); $this->_format = ord($this->_data{0});
$this->_position = Transform::getInt32BE(substr($this->_data, 1, 4)); $this->_position = Transform::getInt32BE(substr($this->_data, 1, 4));
} }

View File

@@ -65,15 +65,8 @@ final class ID3_Frame_USER extends ID3_Frame
* @var Array * @var Array
*/ */
public static $types = array public static $types = array
(0x00 => "Other", ("Other", "Lyrics", "Text transcription", "Movement/Part name", "Eevents",
0x01 => "Lyrics", "Chord", "Trivia", "URLs to webpages", "URLs to images");
0x02 => "Text transcription",
0x03 => "Movement/Part name",
0x04 => "Eevents",
0x05 => "Chord",
0x06 => "Trivia",
0x07 => "URLs to webpages",
0x08 => "URLs to images");
/** @var integer */ /** @var integer */
private $_encoding; private $_encoding;
@@ -102,25 +95,30 @@ final class ID3_Frame_USER extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_encoding = substr($this->_data, 0, 1); $this->_encoding = ord($this->_data{0});
$this->_language = substr($this->_data, 1, 3); $this->_language = substr($this->_data, 1, 3);
$this->_format = substr($this->_data, 3, 1); $this->_format = ord($this->_data{3});
$this->_type = substr($this->_data, 4, 1); $this->_type = ord($this->_data{4});
$this->_data = substr($this->_data, 5);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16: case self::UTF16:
list($this->_description, $this->_data) = $bom = substr($this->_data, 0, 2);
preg_split("/\\x00\\x00/", substr($this->_data, 5), 2); $this->_data = substr($this->_data, 2);
$this->_description = Transform::getString16LE($this->_description); if ($bom == 0xfffe) {
break; list($this->_description, $this->_data) =
preg_split("/\\x00\\x00/", $this->_data, 2);
$this->_description = Transform::getString16LE($this->_description);
break;
}
case self::UTF16BE: case self::UTF16BE:
list($this->_description, $this->_data) = list($this->_description, $this->_data) =
preg_split("/\\x00\\x00/", substr($this->_data, 5), 2); preg_split("/\\x00\\x00/", $this->_data, 2);
$this->_description = Transform::getString16BE($this->_description); $this->_description = Transform::getString16BE($this->_description);
break; break;
default: default:
list($this->_description, $this->_data) = list($this->_description, $this->_data) =
preg_split("/\\x00/", substr($this->_data, 5), 2); preg_split("/\\x00/", $this->_data, 2);
$this->_description = Transform::getString8($this->_description); $this->_description = Transform::getString8($this->_description);
} }

View File

@@ -78,8 +78,7 @@ final class ID3_Frame_SYTC extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_format = substr($this->_data, 0, 1); $this->_format = ord($this->_data{0});
$this->_data = substr($this->_data, 1); // FIXME: Better parsing of data $this->_data = substr($this->_data, 1); // FIXME: Better parsing of data
} }

View File

@@ -74,18 +74,23 @@ final class ID3_Frame_USER extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_encoding = substr($this->_data, 0, 1); $this->_encoding = ord($this->_data{0});
$this->_language = substr($this->_data, 1, 3); $this->_language = substr($this->_data, 1, 3);
$this->_data = substr($this->_data, 4);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16: case self::UTF16:
$this->_text = Transform::getString16LE(substr($this->_data, 4)); $bom = substr($this->_data, 0, 2);
break; $this->_data = substr($this->_data, 2);
if ($bom == 0xfffe) {
$this->_text = Transform::getString16LE($this->_data);
break;
}
case self::UTF16BE: case self::UTF16BE:
$this->_text = Transform::getString16BE(substr($this->_data, 4)); $this->_text = Transform::getString16BE($this->_data);
break; break;
default: default:
$this->_text = Transform::getString8(substr($this->_data, 4)); $this->_text = Transform::getString8($this->_data);
} }
} }

View File

@@ -76,25 +76,30 @@ final class ID3_Frame_USLT extends ID3_Frame
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_encoding = substr($this->_data, 0, 1); $this->_encoding = ord($this->_data{0});
$this->_language = substr($this->_data, 1, 3); $this->_language = substr($this->_data, 1, 3);
$this->_data = substr($this->_data, 4);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16: case self::UTF16:
list ($this->_description, $this->_text) = $bom = substr($this->_data, 0, 2);
preg_split("/\\x00\\x00/", substr($this->_data, 4), 2); $this->_data = substr($this->_data, 2);
$this->_description = Transform::getString16LE($this->_description); if ($bom == 0xfffe) {
$this->_text = Transform::getString16LE($this->_text); list ($this->_description, $this->_text) =
break; preg_split("/\\x00\\x00/", $this->_data, 2);
$this->_description = Transform::getString16LE($this->_description);
$this->_text = Transform::getString16LE($this->_text);
break;
}
case self::UTF16BE: case self::UTF16BE:
list ($this->_description, $this->_text) = list ($this->_description, $this->_text) =
preg_split("/\\x00\\x00/", substr($this->_data, 4), 2); preg_split("/\\x00\\x00/", $this->_data, 2);
$this->_description = Transform::getString16BE($this->_description); $this->_description = Transform::getString16BE($this->_description);
$this->_text = Transform::getString16BE($this->_text); $this->_text = Transform::getString16BE($this->_text);
break; break;
default: default:
list ($this->_description, $this->_text) = list ($this->_description, $this->_text) =
preg_split("/\\x00/", substr($this->_data, 4), 2); preg_split("/\\x00/", $this->_data, 2);
$this->_description = Transform::getString8($this->_description); $this->_description = Transform::getString8($this->_description);
$this->_text = Transform::getString8($this->_text); $this->_text = Transform::getString8($this->_text);
} }

View File

@@ -70,23 +70,29 @@ final class ID3_Frame_WXXX extends ID3_Frame_AbstractLink
{ {
parent::__construct($reader); parent::__construct($reader);
$this->_encoding = substr($this->_data, 0, 1); $this->_encoding = ord($this->_data{0});
$this->_data = substr($this->_data, 1);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16: case self::UTF16:
$chunks = preg_split("/\\x00\\x00/", substr($this->_data, 1)); $bom = substr($this->_data, 0, 2);
$this->_description = Transform::getString16LE($chunks[0]); $this->_data = substr($this->_data, 2);
$this->_link = $chunks[1]; if ($bom == 0xfffe) {
break; list($this->_description, $this->_link) =
preg_split("/\\x00\\x00/", $this->_data, 2);
$this->_description = Transform::getString16LE($this->_description);
break;
}
case self::UTF16BE: case self::UTF16BE:
$chunks = preg_split("/\\x00\\x00/", substr($this->_data, 1)); list($this->_description, $this->_link) =
$this->_description = Transform::getString16BE($chunks[0]); preg_split("/\\x00\\x00/", $this->_data, 2);
$this->_link = $chunks[1]; $this->_description = Transform::getString16BE($this->_description);
break; break;
case self::UTF8: case self::UTF8:
case self::ISO88591: case self::ISO88591:
default: default:
list($this->_description, $this->_link) = list($this->_description, $this->_link) =
preg_split("/\\x00/", substr($this->_data, 1)); preg_split("/\\x00/", $this->_data);
break; break;
} }
} }

View File

@@ -50,10 +50,10 @@
interface ID3_Timing interface ID3_Timing
{ {
/** The timestamp is an absolute time, using MPEG frames as unit. */ /** The timestamp is an absolute time, using MPEG frames as unit. */
const MPEG_FRAMES = 0x01; const MPEG_FRAMES = 1;
/** The timestamp is an absolute time, using milliseconds as unit. */ /** The timestamp is an absolute time, using milliseconds as unit. */
const MILLISECONDS = 0x02; const MILLISECONDS = 2;
/** /**
* Returns the timing format. * Returns the timing format.