Swedish characters in id3 artist field makes author tag in podcast feed empty

Nimo - March 23, 2009 - 13:15
Project:FileField Podcaster
Version:6.x-0.7
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Swedish characters in id3 artist field makes author tag in podcast feed empty.

Workaround that I got working:

Add following to the top of ffpc_row_plugin_podcast.inc

<?php

function unhtmlspecialchars($string)
{
    
$string = str_replace ( '&#229;', 'å', $string );
    
$string = str_replace ( '&#197;', 'Å', $string );
    
$string = str_replace ( '&#228;', 'ä', $string );
    
$string = str_replace ( '&#196;', 'Ä', $string );
    
$string = str_replace ( '&#246;', 'ö', $string );
    
$string = str_replace ( '&#214;', 'Ö', $string );         
    
$string = str_replace ( '&aring;', 'å', $string );
    
$string = str_replace ( '&Aring;', 'Å', $string );
    
$string = str_replace ( '&auml;', 'ä', $string );
    
$string = str_replace ( '&Auml;', 'Ä', $string );
    
$string = str_replace ( '&ouml;', 'ö', $string );
    
$string = str_replace ( '&Ouml;', 'Ö', $string );  
     return
$string;

?>

Search for:

<?php
         
'value' => $info['tags_html']['id3v2']['artist'][0],
?>

and replace the line with:

<?php
         
'value' => unhtmlspecialchars($info['tags_html']['id3v2']['artist'][0]),
?>

Maybe there is an better solution?

#1

Nimo - March 23, 2009 - 13:22

Typo. You should search for $info['tags'] and replace with $info['tags_html'].

Ie:

Search for:

<?php
         
'value' => $info['tags']['id3v2']['artist'][0],
?>
Maybe there is an better solution?

and replace the line with:

<?php
         
'value' => unhtmlspecialchars($info['tags_html']['id3v2']['artist'][0]),
?>

Correct function to add:

<?php
function unhtmlspecialchars($string)
{
    
$string = str_replace ( '&amp;#229;', 'å', $string );
    
$string = str_replace ( '&amp;#197;', 'Å', $string );
    
$string = str_replace ( '&amp;#228;', 'ä', $string );
    
$string = str_replace ( '&amp;#196;', 'Ä', $string );
    
$string = str_replace ( '&amp;#246;', 'ö', $string );
    
$string = str_replace ( '&amp;#214;', 'Ö', $string );         
    
$string = str_replace ( '&aring;', 'å', $string );
    
$string = str_replace ( '&Aring;', 'Å', $string );
    
$string = str_replace ( '&auml;', 'ä', $string );
    
$string = str_replace ( '&Auml;', 'Ä', $string );
    
$string = str_replace ( '&ouml;', 'ö', $string );
    
$string = str_replace ( '&Ouml;', 'Ö', $string );  
     return
$string;

?>

And for some reason my html-entities above got lost and was transformed into real characters - how to write them correctly?
(In the meanwhile replace & with &)

 
 

Drupal is a registered trademark of Dries Buytaert.