Add support for encoding option
git-svn-id: http://php-reader.googlecode.com/svn/trunk@129 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
@@ -59,7 +59,7 @@ final class ID3_Frame_IPLS extends ID3_Frame
|
||||
implements ID3_Encoding
|
||||
{
|
||||
/** @var integer */
|
||||
private $_encoding = ID3_Encoding::UTF8;
|
||||
private $_encoding;
|
||||
|
||||
/** @var Array */
|
||||
private $_people = array();
|
||||
@@ -74,25 +74,32 @@ final class ID3_Frame_IPLS extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader, $options);
|
||||
|
||||
$this->_encoding = $this->getOption("encoding", ID3_Encoding::UTF8);
|
||||
|
||||
if ($reader === null)
|
||||
return;
|
||||
|
||||
$this->_encoding = Transform::fromUInt8($this->_data[0]);
|
||||
$encoding = Transform::fromUInt8($this->_data[0]);
|
||||
$data = substr($this->_data, 1);
|
||||
$order = Transform::MACHINE_ENDIAN_ORDER;
|
||||
switch ($this->_encoding) {
|
||||
switch ($encoding) {
|
||||
case self::UTF16:
|
||||
$data = $this->explodeString16($data);
|
||||
foreach ($data as &$str)
|
||||
$str = Transform::fromString16($str, $order);
|
||||
$str = $this->convertString
|
||||
(Transform::fromString16($str, $order), "utf-16");
|
||||
break;
|
||||
case self::UTF16BE:
|
||||
$data = $this->explodeString16($data);
|
||||
foreach ($data as &$str)
|
||||
$str = Transform::fromString16BE($str);
|
||||
$str = $this->convertString
|
||||
(Transform::fromString16BE($str), "utf-16be");
|
||||
break;
|
||||
case self::UTF8:
|
||||
$data = $this->convertString($this->explodeString8($data), "utf-8");
|
||||
break;
|
||||
default:
|
||||
$data = $this->explodeString8($data);
|
||||
$data = $this->convertString($this->explodeString8($data), "iso-8859-1");
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count($data) - 1; $i += 2)
|
||||
@@ -101,14 +108,25 @@ final class ID3_Frame_IPLS extends ID3_Frame
|
||||
|
||||
/**
|
||||
* Returns the text encoding.
|
||||
*
|
||||
*
|
||||
* All the strings read from a file are automatically converted to the
|
||||
* character encoding specified with the <var>encoding</var> option. See
|
||||
* {@link ID3v2} for details. This method returns the original text encoding
|
||||
* used to write the frame.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getEncoding() { return $this->_encoding; }
|
||||
|
||||
/**
|
||||
* Sets the text encoding.
|
||||
*
|
||||
*
|
||||
* All the string written to the frame are done so using given character
|
||||
* encoding. No conversions of existing data take place upon the call to this
|
||||
* method thus all texts must be given in given character encoding.
|
||||
*
|
||||
* The default character encoding used to write the frame is UTF-8.
|
||||
*
|
||||
* @see ID3_Encoding
|
||||
* @param integer $encoding The text encoding.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user