本文整理匯總了PHP中getid3_lib::MultiByteCharString2HTML方法的典型用法代碼示例。如果您正苦於以下問題:PHP getid3_lib::MultiByteCharString2HTML方法的具體用法?PHP getid3_lib::MultiByteCharString2HTML怎麽用?PHP getid3_lib::MultiByteCharString2HTML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類getid3_lib
的用法示例。
在下文中一共展示了getid3_lib::MultiByteCharString2HTML方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: CopyTagsToComments
static function CopyTagsToComments(&$ThisFileInfo)
{
// Copy all entries from ['tags'] into common ['comments']
if (!empty($ThisFileInfo['tags'])) {
foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
foreach ($tagarray as $tagname => $tagdata) {
foreach ($tagdata as $key => $value) {
if (!empty($value)) {
if (empty($ThisFileInfo['comments'][$tagname])) {
// fall through and append value
} elseif ($tagtype == 'id3v1') {
$newvaluelength = strlen(trim($value));
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
$oldvaluelength = strlen(trim($existingvalue));
if ($newvaluelength <= $oldvaluelength && substr($existingvalue, 0, $newvaluelength) == trim($value)) {
// new value is identical but shorter-than (or equal-length to) one already in comments - skip
break 2;
}
}
} else {
$newvaluelength = strlen(trim($value));
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
$oldvaluelength = strlen(trim($existingvalue));
if ($newvaluelength > $oldvaluelength && substr(trim($value), 0, strlen($existingvalue)) == $existingvalue) {
$ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
break 2;
}
}
}
if (empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
$ThisFileInfo['comments'][$tagname][] = trim($value);
}
}
}
}
}
// Copy to ['comments_html']
foreach ($ThisFileInfo['comments'] as $field => $values) {
foreach ($values as $index => $value) {
$ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', getid3_lib::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
}
}
}
}
示例2: HandleAllTags
function HandleAllTags()
{
// key name => array (tag name, character encoding)
static $tags;
if (empty($tags)) {
$tags = array('asf' => array('asf', 'UTF-16LE'), 'midi' => array('midi', 'ISO-8859-1'), 'nsv' => array('nsv', 'ISO-8859-1'), 'ogg' => array('vorbiscomment', 'UTF-8'), 'png' => array('png', 'UTF-8'), 'tiff' => array('tiff', 'ISO-8859-1'), 'quicktime' => array('quicktime', 'UTF-8'), 'real' => array('real', 'ISO-8859-1'), 'vqf' => array('vqf', 'ISO-8859-1'), 'zip' => array('zip', 'ISO-8859-1'), 'riff' => array('riff', 'ISO-8859-1'), 'lyrics3' => array('lyrics3', 'ISO-8859-1'), 'id3v1' => array('id3v1', $this->encoding_id3v1), 'id3v2' => array('id3v2', 'UTF-8'), 'ape' => array('ape', 'UTF-8'), 'cue' => array('cue', 'ISO-8859-1'), 'matroska' => array('matroska', 'UTF-8'));
}
// loop through comments array
foreach ($tags as $comment_name => $tagname_encoding_array) {
list($tag_name, $encoding) = $tagname_encoding_array;
// fill in default encoding type if not already present
if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
$this->info[$comment_name]['encoding'] = $encoding;
}
// copy comments if key name set
if (!empty($this->info[$comment_name]['comments'])) {
foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
foreach ($valuearray as $key => $value) {
if (is_string($value)) {
$value = trim($value, " \r\n\t");
// do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed!
}
if ($value) {
$this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value;
}
}
}
if (!isset($this->info['tags'][$tag_name])) {
// comments are set but contain nothing but empty strings, so skip
continue;
}
if ($this->option_tags_html) {
foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
foreach ($valuearray as $key => $value) {
if (is_string($value)) {
//$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);
$this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('�', '', trim(getid3_lib::MultiByteCharString2HTML($value, $encoding)));
} else {
$this->info['tags_html'][$tag_name][$tag_key][$key] = $value;
}
}
}
}
$this->CharConvert($this->info['tags'][$tag_name], $encoding);
// only copy gets converted!
}
}
// pictures can take up a lot of space, and we don't need multiple copies of them
// let there be a single copy in [comments][picture], and not elsewhere
if (!empty($this->info['tags'])) {
$unset_keys = array('tags', 'tags_html');
foreach ($this->info['tags'] as $tagtype => $tagarray) {
foreach ($tagarray as $tagname => $tagdata) {
if ($tagname == 'picture') {
foreach ($tagdata as $key => $tagarray) {
$this->info['comments']['picture'][] = $tagarray;
if (isset($tagarray['data']) && isset($tagarray['image_mime'])) {
if (isset($this->info['tags'][$tagtype][$tagname][$key])) {
unset($this->info['tags'][$tagtype][$tagname][$key]);
}
if (isset($this->info['tags_html'][$tagtype][$tagname][$key])) {
unset($this->info['tags_html'][$tagtype][$tagname][$key]);
}
}
}
}
}
foreach ($unset_keys as $unset_key) {
// remove possible empty keys from (e.g. [tags][id3v2][picture])
if (empty($this->info[$unset_key][$tagtype]['picture'])) {
unset($this->info[$unset_key][$tagtype]['picture']);
}
if (empty($this->info[$unset_key][$tagtype])) {
unset($this->info[$unset_key][$tagtype]);
}
if (empty($this->info[$unset_key])) {
unset($this->info[$unset_key]);
}
}
// remove duplicate copy of picture data from (e.g. [id3v2][comments][picture])
if (isset($this->info[$tagtype]['comments']['picture'])) {
unset($this->info[$tagtype]['comments']['picture']);
}
if (empty($this->info[$tagtype]['comments'])) {
unset($this->info[$tagtype]['comments']);
}
if (empty($this->info[$tagtype])) {
unset($this->info[$tagtype]);
}
}
}
return true;
}
示例3: HandleAllTags
function HandleAllTags()
{
// key name => array (tag name, character encoding)
static $tags;
if (empty($tags)) {
$tags = array('asf' => array('asf', 'UTF-16LE'), 'midi' => array('midi', 'ISO-8859-1'), 'nsv' => array('nsv', 'ISO-8859-1'), 'ogg' => array('vorbiscomment', 'UTF-8'), 'png' => array('png', 'UTF-8'), 'tiff' => array('tiff', 'ISO-8859-1'), 'quicktime' => array('quicktime', 'ISO-8859-1'), 'real' => array('real', 'ISO-8859-1'), 'vqf' => array('vqf', 'ISO-8859-1'), 'zip' => array('zip', 'ISO-8859-1'), 'riff' => array('riff', 'ISO-8859-1'), 'lyrics3' => array('lyrics3', 'ISO-8859-1'), 'id3v1' => array('id3v1', $this->encoding_id3v1), 'id3v2' => array('id3v2', 'UTF-8'), 'ape' => array('ape', 'UTF-8'));
}
// loop thru comments array
foreach ($tags as $comment_name => $tagname_encoding_array) {
list($tag_name, $encoding) = $tagname_encoding_array;
// fill in default encoding type if not already present
if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
$this->info[$comment_name]['encoding'] = $encoding;
}
// copy comments if key name set
if (!empty($this->info[$comment_name]['comments'])) {
foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
foreach ($valuearray as $key => $value) {
if (strlen(trim($value)) > 0) {
$this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value;
// do not trim!! Unicode characters will get mangled if trailing nulls are removed!
}
}
}
if (!isset($this->info['tags'][$tag_name])) {
// comments are set but contain nothing but empty strings, so skip
continue;
}
if ($this->option_tags_html) {
foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
foreach ($valuearray as $key => $value) {
if (is_string($value)) {
//$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);
$this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('�', '', getid3_lib::MultiByteCharString2HTML($value, $encoding));
} else {
$this->info['tags_html'][$tag_name][$tag_key][$key] = $value;
}
}
}
}
$this->CharConvert($this->info['tags'][$tag_name], $encoding);
// only copy gets converted!
}
}
return true;
}
示例4: CopyTagsToComments
static function CopyTagsToComments(&$ThisFileInfo)
{
// Copy all entries from ['tags'] into common ['comments']
if (!empty($ThisFileInfo['tags'])) {
foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
foreach ($tagarray as $tagname => $tagdata) {
foreach ($tagdata as $key => $value) {
if (!empty($value)) {
if (empty($ThisFileInfo['comments'][$tagname])) {
// fall through and append value
} elseif ($tagtype == 'id3v1') {
$newvaluelength = strlen(trim($value));
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
$oldvaluelength = strlen(trim($existingvalue));
if ($newvaluelength <= $oldvaluelength && substr($existingvalue, 0, $newvaluelength) == trim($value)) {
// new value is identical but shorter-than (or equal-length to) one already in comments - skip
break 2;
}
}
} elseif (!is_array($value)) {
$newvaluelength = strlen(trim($value));
foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
$oldvaluelength = strlen(trim($existingvalue));
if ($newvaluelength > $oldvaluelength && substr(trim($value), 0, strlen($existingvalue)) == $existingvalue) {
$ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
break 2;
}
}
}
if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
$value = is_string($value) ? trim($value) : $value;
$ThisFileInfo['comments'][$tagname][] = $value;
}
}
}
}
}
// Copy to ['comments_html']
foreach ($ThisFileInfo['comments'] as $field => $values) {
if ($field == 'picture') {
// pictures can take up a lot of space, and we don't need multiple copies of them
// let there be a single copy in [comments][picture], and not elsewhere
continue;
}
foreach ($values as $index => $value) {
if (is_array($value)) {
$ThisFileInfo['comments_html'][$field][$index] = $value;
} else {
$ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', getid3_lib::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
}
}
}
}
return true;
}