Fix a defect in unicode handling

git-svn-id: http://php-reader.googlecode.com/svn/trunk@144 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2009-03-25 20:02:05 +00:00
parent aeadea825d
commit 618d083fad
12 changed files with 75 additions and 144 deletions

View File

@@ -124,13 +124,13 @@ final class ID3_Frame_APIC extends ID3_Frame
list ($this->_description, $this->_imageData) = list ($this->_description, $this->_imageData) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16($this->_description), "utf-16"); ($this->_description, "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
list ($this->_description, $this->_imageData) = list ($this->_description, $this->_imageData) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16BE($this->_description), "utf-16be"); ($this->_description, "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
list ($this->_description, $this->_imageData) = list ($this->_description, $this->_imageData) =
@@ -258,15 +258,12 @@ final class ID3_Frame_APIC extends ID3_Frame
$data = Transform::toUInt8($this->_encoding) . $this->_mimeType . "\0" . $data = Transform::toUInt8($this->_encoding) . $this->_mimeType . "\0" .
Transform::toUInt8($this->_imageType); Transform::toUInt8($this->_imageType);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$data .= Transform::toString16 $data .= 0xfeff . $this->_description . "\0\0";
($this->_description, $this->_encoding == self::UTF16 ?
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER) .
"\0\0";
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE($this->_description) . "\0\0"; $data .= $this->_description . "\0\0";
break; break;
default: default:
$data .= $this->_description . "\0"; $data .= $this->_description . "\0";

View File

@@ -89,13 +89,11 @@ abstract class ID3_Frame_AbstractText extends ID3_Frame
switch ($encoding) { switch ($encoding) {
case self::UTF16: case self::UTF16:
$this->_text = $this->_convertString $this->_text = $this->_convertString
($this->_explodeString16(Transform::fromString16($this->_data)), ($this->_explodeString16($this->_data), "utf-16");
"utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
$this->_text = $this->_convertString $this->_text = $this->_convertString
($this->_explodeString16(Transform::fromString16BE($this->_data)), ($this->_explodeString16($this->_data), "utf-16be");
"utf-16be");
break; break;
case self::UTF8: case self::UTF8:
$this->_text = $this->_convertString $this->_text = $this->_convertString
@@ -170,17 +168,12 @@ abstract class ID3_Frame_AbstractText extends ID3_Frame
{ {
$data = Transform::toUInt8($this->_encoding); $data = Transform::toUInt8($this->_encoding);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$array = $this->_text; $data .= 0xfeff . implode(0xfeff . "\0\0", $this->_text);
foreach ($array as &$text)
$text = Transform::toString16($text);
$data .= Transform::toString16
(implode("\0\0", $array), $this->_encoding == self::UTF16 ?
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER);
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE(implode("\0\0", $this->_text)); $data .= implode("\0\0", $this->_text);
break; break;
default: default:
$data .= implode("\0", $this->_text); $data .= implode("\0", $this->_text);

View File

@@ -100,17 +100,16 @@ final class ID3_Frame_COMM extends ID3_Frame
list ($this->_description, $this->_text) = list ($this->_description, $this->_text) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16($this->_description), "utf-16"); ($this->_description, "utf-16");
$this->_text = $this->_convertString $this->_text = $this->_convertString($this->_text, "utf-16");
(Transform::fromString16($this->_text), "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
list ($this->_description, $this->_text) = list ($this->_description, $this->_text) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16BE($this->_description), "utf-16be"); ($this->_description, "utf-16be");
$this->_text = $this->_convertString $this->_text = $this->_convertString
(Transform::fromString16BE($this->_text), "utf-16be"); ($this->_text, "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
list ($this->_description, $this->_text) = list ($this->_description, $this->_text) =
@@ -236,16 +235,12 @@ final class ID3_Frame_COMM extends ID3_Frame
{ {
$data = Transform::toUInt8($this->_encoding) . $this->_language; $data = Transform::toUInt8($this->_encoding) . $this->_language;
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$order = $this->_encoding == self::UTF16 ? $data .= 0xfeff . $this->_description . "\0\0" . 0xfeff . $this->_text;
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER;
$data .= Transform::toString16($this->_description, $order) . "\0\0" .
Transform::toString16($this->_text, $order);
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE $data .= $this->_description . "\0\0" . $this->_text;
($this->_description . "\0\0" . $this->_text);
break; break;
default: default:
$data .= $this->_description . "\0" . $this->_text; $data .= $this->_description . "\0" . $this->_text;

View File

@@ -135,18 +135,16 @@ final class ID3_Frame_COMR extends ID3_Frame
case self::UTF16: case self::UTF16:
list ($this->_seller, $this->_description, $this->_data) = list ($this->_seller, $this->_description, $this->_data) =
$this->_explodeString16($this->_data, 3); $this->_explodeString16($this->_data, 3);
$this->_seller = $this->_convertString $this->_seller = $this->_convertString($this->_seller, "utf-16");
(Transform::fromString16($this->_seller), "utf-16");
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16($this->_description), "utf-16"); ($this->_description, "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
list ($this->_seller, $this->_description, $this->_data) = list ($this->_seller, $this->_description, $this->_data) =
$this->_explodeString16($this->_data, 3); $this->_explodeString16($this->_data, 3);
$this->_seller = $this->_convertString $this->_seller = $this->_convertString($this->_seller, "utf-16be");
(Transform::fromString16BE($this->_seller), "utf-16be");
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16BE($this->_description), "utf-16be"); ($this->_description, "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
list ($this->_seller, $this->_description, $this->_data) = list ($this->_seller, $this->_description, $this->_data) =
@@ -379,16 +377,13 @@ final class ID3_Frame_COMR extends ID3_Frame
$this->_price . "\0" . $this->_date . $this->_contact . "\0" . $this->_price . "\0" . $this->_date . $this->_contact . "\0" .
Transform::toUInt8($this->_delivery); Transform::toUInt8($this->_delivery);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$order = $this->_encoding == self::UTF16 ? $data .= 0xfeff . $this->_seller . "\0\0" . 0xfeff .
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER; $this->_description . "\0\0";
$data .= Transform::toString16($this->_seller, $order) . "\0\0" .
Transform::toString16($this->_description, $order) . "\0\0";
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE $data .= $this->_seller . "\0\0" . $this->_description . "\0\0";
($this->_seller . "\0\0" . $this->_description . "\0\0");
break; break;
default: default:
$data .= $this->_seller . "\0" . $this->_description . "\0"; $data .= $this->_seller . "\0" . $this->_description . "\0";

View File

@@ -95,18 +95,16 @@ final class ID3_Frame_GEOB extends ID3_Frame
case self::UTF16: case self::UTF16:
list ($this->_filename, $this->_description, $this->_objectData) = list ($this->_filename, $this->_description, $this->_objectData) =
$this->_explodeString16($this->_data, 3); $this->_explodeString16($this->_data, 3);
$this->_filename = $this->_convertString $this->_filename = $this->_convertString($this->_filename, "utf-16");
(Transform::fromString16($this->_filename), "utf-16");
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16($this->_description), "utf-16"); ($this->_description, "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
list ($this->_filename, $this->_description, $this->_objectData) = list ($this->_filename, $this->_description, $this->_objectData) =
$this->_explodeString16($this->_data, 3); $this->_explodeString16($this->_data, 3);
$this->_filename = $this->_convertString $this->_filename = $this->_convertString($this->_filename, "utf-16be");
(Transform::fromString16BE($this->_filename), "utf-16be");
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16BE($this->_description), "utf-16be"); ($this->_description, "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
list ($this->_filename, $this->_description, $this->_objectData) = list ($this->_filename, $this->_description, $this->_objectData) =
@@ -234,16 +232,13 @@ final class ID3_Frame_GEOB extends ID3_Frame
{ {
$data = Transform::toUInt8($this->_encoding) . $this->_mimeType . "\0"; $data = Transform::toUInt8($this->_encoding) . $this->_mimeType . "\0";
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$order = $this->_encoding == self::UTF16 ? $data .= 0xfeff . $this->_filename . "\0\0" . 0xfeff .
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER; $this->_description . "\0\0";
$data .= Transform::toString16($this->_filename, $order) . "\0\0" .
Transform::toString16($this->_description, $order) . "\0\0";
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE $data .= $this->_filename . "\0\0" . $this->_description . "\0\0";
($this->_filename . "\0\0" . $this->_description . "\0\0");
break; break;
default: default:
$data .= $this->_filename . "\0" . $this->_description . "\0"; $data .= $this->_filename . "\0" . $this->_description . "\0";

View File

@@ -82,25 +82,23 @@ final class ID3_Frame_IPLS extends ID3_Frame
$encoding = Transform::fromUInt8($this->_data[0]); $encoding = Transform::fromUInt8($this->_data[0]);
$data = substr($this->_data, 1); $data = substr($this->_data, 1);
$order = Transform::MACHINE_ENDIAN_ORDER;
switch ($encoding) { switch ($encoding) {
case self::UTF16: case self::UTF16:
$data = $this->_explodeString16($data); $data = $this->_explodeString16($data);
foreach ($data as &$str) foreach ($data as &$str)
$str = $this->_convertString $str = $this->_convertString($str, "utf-16");
(Transform::fromString16($str, $order), "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
$data = $this->_explodeString16($data); $data = $this->_explodeString16($data);
foreach ($data as &$str) foreach ($data as &$str)
$str = $this->_convertString $str = $this->_convertString($str, "utf-16be");
(Transform::fromString16BE($str), "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
$data = $this->_convertString($this->_explodeString8($data), "utf-8"); $data = $this->_convertString($this->_explodeString8($data), "utf-8");
break; break;
default: default:
$data = $this->_convertString($this->_explodeString8($data), "iso-8859-1"); $data = $this->_convertString
($this->_explodeString8($data), "iso-8859-1");
} }
for ($i = 0; $i < count($data) - 1; $i += 2) for ($i = 0; $i < count($data) - 1; $i += 2)
@@ -169,18 +167,15 @@ final class ID3_Frame_IPLS extends ID3_Frame
protected function _getData() protected function _getData()
{ {
$data = Transform::toUInt8($this->_encoding); $data = Transform::toUInt8($this->_encoding);
$order = $this->_encoding == self::UTF16 ?
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER;
foreach ($this->_people as $entry) { foreach ($this->_people as $entry) {
foreach ($entry as $key => $val) { foreach ($entry as $key => $val) {
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$data .= Transform::toString16($key, $order) . "\0\0" . $data .= 0xfeff . $key . "\0\0" . 0xfeff . $val . "\0\0";
Transform::toString16($val, $order) . "\0\0";
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE($key . "\0\0" . $val . "\0\0"); $data .= $key . "\0\0" . $val . "\0\0";
break; break;
default: default:
$data .= $key . "\0" . $val . "\0"; $data .= $key . "\0" . $val . "\0";

View File

@@ -99,12 +99,10 @@ final class ID3_Frame_OWNE extends ID3_Frame
switch ($encoding) { switch ($encoding) {
case self::UTF16: case self::UTF16:
$this->_seller = $this->_convertString $this->_seller = $this->_convertString($this->_data, "utf-16");
(Transform::fromString16($this->_data), "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
$this->_seller = $this->_convertString $this->_seller = $this->_convertString($this->_data, "utf-16be");
(Transform::fromString16BE($this->_data), "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
$this->_seller = $this->_convertString $this->_seller = $this->_convertString
@@ -222,14 +220,8 @@ final class ID3_Frame_OWNE extends ID3_Frame
$data = Transform::toUInt8($this->_encoding) . $this->_currency . $data = Transform::toUInt8($this->_encoding) . $this->_currency .
$this->_price . "\0" . $this->_date; $this->_price . "\0" . $this->_date;
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$data .= Transform::toString16 $data .= 0xfeff . $this->_seller;
($this->_seller, $this->_encoding == self::UTF16 ?
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER);
break;
case self::UTF16BE:
$data .= Transform::toString16BE($this->_seller);
break; break;
default: default:
$data .= $this->_seller; $data .= $this->_seller;

View File

@@ -118,13 +118,13 @@ final class ID3_Frame_SYLT extends ID3_Frame
list($this->_description, $this->_data) = list($this->_description, $this->_data) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16($this->_description), "utf-16"); ($this->_description, "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
list($this->_description, $this->_data) = list($this->_description, $this->_data) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16BE($this->_description), "utf-16be"); ($this->_description, "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
list($this->_description, $this->_data) = list($this->_description, $this->_data) =
@@ -144,14 +144,12 @@ final class ID3_Frame_SYLT extends ID3_Frame
case self::UTF16: case self::UTF16:
list($syllable, $this->_data) = list($syllable, $this->_data) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$syllable = $this->_convertString $syllable = $this->_convertString($syllable, "utf-16");
(Transform::fromString16($syllable), "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
list($syllable, $this->_data) = list($syllable, $this->_data) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$syllable = $this->_convertString $syllable = $this->_convertString($syllable, "utf-16be");
(Transform::fromString16BE($syllable), "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
list($syllable, $this->_data) = list($syllable, $this->_data) =
@@ -309,30 +307,24 @@ final class ID3_Frame_SYLT extends ID3_Frame
$data = Transform::toUInt8($this->_encoding) . $this->_language . $data = Transform::toUInt8($this->_encoding) . $this->_language .
Transform::toUInt8($this->_format) . Transform::toUInt8($this->_type); Transform::toUInt8($this->_format) . Transform::toUInt8($this->_type);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$data .= Transform::toString16 $data .= 0xfeff . $this->_description . "\0\0";
($this->_description, $this->_encoding == self::UTF16 ?
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER) .
"\0\0";
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE($this->_description) . "\0\0"; $data .= $this->_description . "\0\0";
break; break;
default: default:
$data .= $this->_description . "\0"; $data .= $this->_description . "\0";
} }
foreach ($this->_events as $timestamp => $syllable) { foreach ($this->_events as $timestamp => $syllable) {
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$data .= Transform::toString16 $data .= 0xfeff . $syllable . "\0\0";
($syllable, $this->_encoding == self::UTF16 ?
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER) .
"\0\0";
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE($syllable) . "\0\0"; $data .= $syllable . "\0\0";
break; break;
default: default:
$data .= $syllable . "\0"; $data .= $syllable . "\0";

View File

@@ -86,17 +86,16 @@ final class ID3_Frame_TXXX extends ID3_Frame_AbstractText
list($this->_description, $this->_text) = list($this->_description, $this->_text) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16($this->_description), "utf-16"); ($this->_description, "utf-16");
$this->_text = $this->_convertString $this->_text = $this->_convertString(array($this->_text), "utf-16");
(array(Transform::fromString16($this->_text)), "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
list($this->_description, $this->_text) = list($this->_description, $this->_text) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16BE($this->_description), "utf-16be"); ($this->_description, "utf-16be");
$this->_text = $this->_convertString $this->_text = $this->_convertString
(array(Transform::fromString16BE($this->_text)), "utf-16be"); (array($this->_text), "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
list($this->_description, $this->_text) = $this->_convertString list($this->_description, $this->_text) = $this->_convertString
@@ -139,16 +138,12 @@ final class ID3_Frame_TXXX extends ID3_Frame_AbstractText
{ {
$data = Transform::toUInt8($this->_encoding); $data = Transform::toUInt8($this->_encoding);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$order = $this->_encoding == self::UTF16 ? $data .= 0xfeff . $this->_description . "\0\0" . 0xfeff . $this->_text[0];
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER;
$data .= Transform::toString16($this->_description, $order) . "\0\0" .
Transform::toString16($this->_text[0], $order);
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE($this->_description) . "\0\0" . $data .= $this->_description . "\0\0" . $this->_text[0];
Transform::toString16BE($this->_text[0]);
break; break;
default: default:
$data .= $this->_description . "\0" . $this->_text[0]; $data .= $this->_description . "\0" . $this->_text[0];

View File

@@ -92,12 +92,10 @@ final class ID3_Frame_USER extends ID3_Frame
switch ($encoding) { switch ($encoding) {
case self::UTF16: case self::UTF16:
$this->_text = $this->_convertString $this->_text = $this->_convertString($this->_data, "utf-16");
(Transform::fromString16($this->_data), "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
$this->_text = $this->_convertString $this->_text = $this->_convertString($this->_data, "utf-16be");
(Transform::fromString16BE($this->_data), "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
$this->_text = $this->_convertString $this->_text = $this->_convertString
@@ -189,15 +187,8 @@ final class ID3_Frame_USER extends ID3_Frame
{ {
$data = Transform::toUInt8($this->_encoding) . $this->_language; $data = Transform::toUInt8($this->_encoding) . $this->_language;
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$data .= Transform::toString16 $data .= 0xfeff . $this->_text;
($this->_text, $this->_encoding == self::UTF16 ?
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER);
break;
case self::UTF16BE:
$data .= Transform::toString16BE($this->_text);
break;
default: default:
$data .= $this->_text; $data .= $this->_text;
} }

View File

@@ -97,17 +97,15 @@ final class ID3_Frame_USLT extends ID3_Frame
list ($this->_description, $this->_text) = list ($this->_description, $this->_text) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16($this->_description), "utf-16"); ($this->_description, "utf-16");
$this->_text = $this->_convertString $this->_text = $this->_convertString($this->_text, "utf-16");
(Transform::fromString16($this->_text), "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
list ($this->_description, $this->_text) = list ($this->_description, $this->_text) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16BE($this->_description), "utf-16be"); ($this->_description, "utf-16be");
$this->_text = $this->_convertString $this->_text = $this->_convertString($this->_text, "utf-16be");
(Transform::fromString16BE($this->_text), "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
list ($this->_description, $this->_text) = list ($this->_description, $this->_text) =
@@ -233,16 +231,12 @@ final class ID3_Frame_USLT extends ID3_Frame
{ {
$data = Transform::toUInt8($this->_encoding) . $this->_language; $data = Transform::toUInt8($this->_encoding) . $this->_language;
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$order = $this->_encoding == self::UTF16 ? $data .= 0xfeff . $this->_description . "\0\0" . 0xfeff . $this->_text;
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER;
$data .= Transform::toString16($this->_description, $order) . "\0\0" .
Transform::toString16($this->_text, $order);
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE($this->_description) . "\0\0" . $data .= $this->_description . "\0\0" . $this->_text;
Transform::toString16BE($this->_text);
break; break;
default: default:
$data .= $this->_description . "\0" . $this->_text; $data .= $this->_description . "\0" . $this->_text;

View File

@@ -88,13 +88,13 @@ final class ID3_Frame_WXXX extends ID3_Frame_AbstractLink
list($this->_description, $this->_link) = list($this->_description, $this->_link) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16($this->_description), "utf-16"); ($this->_description, "utf-16");
break; break;
case self::UTF16BE: case self::UTF16BE:
list($this->_description, $this->_link) = list($this->_description, $this->_link) =
$this->_explodeString16($this->_data, 2); $this->_explodeString16($this->_data, 2);
$this->_description = $this->_convertString $this->_description = $this->_convertString
(Transform::fromString16BE($this->_description), "utf-16be"); ($this->_description, "utf-16be");
break; break;
case self::UTF8: case self::UTF8:
list($this->_description, $this->_link) = list($this->_description, $this->_link) =
@@ -165,15 +165,12 @@ final class ID3_Frame_WXXX extends ID3_Frame_AbstractLink
{ {
$data = Transform::toUInt8($this->_encoding); $data = Transform::toUInt8($this->_encoding);
switch ($this->_encoding) { switch ($this->_encoding) {
case self::UTF16:
case self::UTF16LE: case self::UTF16LE:
$data .= Transform::toString16 $data .= 0xfeff . $this->_description . "\0\0";
($this->_description, $this->_encoding == self::UTF16 ?
Transform::MACHINE_ENDIAN_ORDER : Transform::LITTLE_ENDIAN_ORDER) .
"\0\0";
break; break;
case self::UTF16:
case self::UTF16BE: case self::UTF16BE:
$data .= Transform::toString16BE($this->_description) . "\0\0"; $data .= $this->_description . "\0\0";
break; break;
default: default:
$data .= $this->_description . "\0"; $data .= $this->_description . "\0";