Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: Utf-8

  1. #1
    New Coder
    Join Date
    Sep 2009
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Utf-8

    hallo guys i have a problem so here is a script :


    (here the url: http://www.inthemixradio.lu/onair.php)

    the files like etc are showed as ? ?

    on the php site

    exp:

    J?nnif?r Lop?z - Papi

    but it needs to be:

    J?nnif?r Lop?z - Papi


    -------------------------------------------


    PHP Code:
    [CODE]<?php

    // @----------------------------------------------------------------------@
    // | PHP ONAIR  1.0                                                       |
    // @----------------------------------------------------------------------@
    // | Copyright Ā© 2012 Olivier NoĆ«l , South Music Luxembourg a.s.b.l.      |
    // @----------------------------------------------------------------------@
    // | Author: Olivier NoĆ«l <stilnoct@me.com>                               |
    // @----------------------------------------------------------------------@
    // 
    // ONAIR.php Version 1.0 30/11/2012
    // @----------------------------------------------------------------------@
    // | READ INSTALLATION INSTRUCTIONS BEFORE                                |
    // | ask it <stilnoct@me.com>                                             |
    // @----------------------------------------------------------------------@
    function saveChildren($element)
    {
        global 
    $elements;
        foreach(
    $element->children() as $child)
        {
              
    $elements[$child->getName()] = $child;
              
    saveChildren($child);
        }
    }
    function 
    getAttribute($element$attr)
    {
        foreach (
    $element->attributes() AS $key => $attribute)
        {
            if (
    $key == $attr) return $attribute;
        }
    }
    global 
    $elements;
    // @----------------------------------------------------------------------@
    // | NOW ON AIR XML phath                                                 |
    // @----------------------------------------------------------------------@
    if (file_exists("onair/NowOnAir.xml"))
    {
        
    $xmlstring utf8_decode(file_get_contents("onair/NowOnAir.xml"));
        
    $xmlstring str_replace("&""and"$xmlstring);
        
    $xml simplexml_load_string($xmlstring);
        
        
    saveChildren($xml);

        foreach (
    $elements AS $key => $elmnt)
        {    
            switch (
    $key)
            {
                case 
    "Song":
                    
    $actsongtitle getAttribute($elmnt"title");
                break;
            
                case 
    "Artist":
                    
    $actartistname getAttribute($elmnt"name");
                break;
            }
        }
        
    $act_onair true;
    }
    if (
    $act_onair === true)
    {
        
    $act_string $actartistname." - ".$actsongtitle;
        if (
    $songs[0] != $act_string)
        {
            
    $txt $act_string."\n";
            {
            }
        }
    }
    // @----------------------------------------------------------------------@
    // | HERE YOU CAN CHANGE THE TEXT : NOW ON AIR                            |
    // | COLOR STYLE ETC                                                      |
    // @----------------------------------------------------------------------@
    echo "
    <html>
    <head>
    <meta http-equiv='refresh' content='30'>
    </head>
    <body style='background-color:transparent;';>
    <div style='font-size:11; color:#AAAAAA; font-family:Verdana,Arial;'>"
    ;
    echo 
    "<span style='font-weight:slim; color:#EC7906;'>NOW ON AIR :</span><br>".htmlentities($act_string);
    // @----------------------------------------------------------------------@
    // | NEXT ON AIR XML phath                                                |
    // @----------------------------------------------------------------------@
    if (file_exists("onair/AirPlayNext.xml"))
    {
        
    $xmlstring utf8_decode(file_get_contents("onair/AirPlayNext.xml"));
        
    $xmlstring str_replace("&""and"$xmlstring);
        
    $xml simplexml_load_string($xmlstring);
        
        
    saveChildren($xml);

        foreach (
    $elements AS $key => $elmnt)
        {    
            switch (
    $key)
            {
                case 
    "Song":
                    
    $actsongtitle getAttribute($elmnt"title");
                break;
            
                case 
    "Artist":
                    
    $actartistname getAttribute($elmnt"name");
                break;
            }
        }
        
    $act_onair true;
    }

    $t file_get_contents("onair/last5.txt");
    $songs explode("\n"$t);

    if (
    $act_onair === true)
    {
        
    $act_string $actartistname." - ".$actsongtitle;
        if (
    $songs[0] != $act_string)
        {
            
    $txt $act_string."\n";
    // @----------------------------------------------------------------------@
    // | LAST PLAYED   "for ($i=0; $i<1; $i++) = 1  SONG , 2 = 2 SONGS        |
    // @----------------------------------------------------------------------@
            
    for ($i=-0$i<7$i++)
            {
                if (
    $songs[$i] != ""$txt .= $songs[$i]."\n";
            }
            
    file_put_contents("onair/last5.txt"$txt);
            
    $t file_get_contents("onair/last5.txt");
            
    $songs explode("\n"$t);
        }
    }

    // @----------------------------------------------------------------------@
    // | HERE YOU CAN CHANGE THE TEXT : NEXT ON AIR , LAST 6 PLAYED           |
    // | COLOR STYLE ETC                                                      |
    // @----------------------------------------------------------------------@

    echo "
    <html>
    <head>
    <meta http-equiv='refresh' content='15'>
    </head>
    <body style='background-color:transparent;';>
    <div style='font-size:11; color:#AAAAAA; font-family:Verdana,Arial;'>"
    ;
    echo 
    "<br><span style='font-weight:slim; color:#EC7906;'>COMING UP :</span><br>".htmlentities($act_string);
    echo 
    "<br><br><span style='font-weight:slim; color:#EC7906;'>LAST PLAYED :</span><br>";
    $c count($songs);
    for (
    $i=2$i<$c$i++) echo htmlentities($songs[$i])."<br>";
    // @----------------------------------------------------------------------@
    // | YOU ARE NOT PERMITTED TO REMOVE, CHANGE OR DELETE THE NEXT FILES     |
    // @----------------------------------------------------------------------@
    echo "</div>";
    echo 
    "
    <div>"
    ;
    echo 
    "<span style='font-weight:smal; font-size:11; font-family:Verdana,Arial;'color:#EC7906;'></span><br>";
    ?>[/CODE]
    Last edited by Bonzai; 12-01-2012 at 04:07 PM.

  • #2
    New Coder
    Join Date
    Sep 2009
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Utf-8 php

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Does the XML contain the ?'s or does it contain the proper accented characters? If the XML already contains those, then the file source itself is of no use as the damage is at the storage level for the data. If its just the desplay, make sure you push the utf8 charsets with header('Content-type: text/html; charset=utf-8'); at the top of the script. Make sure that the XML has been stored in a UTF8 format as well.

  • #4
    New Coder
    Join Date
    Sep 2009
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <Schedule System="Jazler">
     <Event status="happening" startTime="17:52:46" eventType="song">
        <Announcement Display=""/>
      <Song title="Yenn - Elake Anthem 2008 (Radio Edit)">
       <Artist name="Yenn">
       </Artist>
        <Jazler ID="268"/>
        <PlayLister ID=""/>
        <Media runTime="04:20"/>
        <Expire Time="17:57:06"/>
      </Song>
     </Event>
    </Schedule>

  • #5
    New Coder
    Join Date
    Sep 2009
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    this is the file the xml file i get from the radio automation program i can not change them!

  • #6
    New Coder
    Join Date
    Sep 2009
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    like this?

    d'ont works

    Code:
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>ON AIR 1.0</title>
    </head>
    <?php
    
    // @----------------------------------------------------------------------@
    // | PHP ONAIR  1.0                                                       |
    // @----------------------------------------------------------------------@
    // | Copyright Ā© 2012 Olivier NoĆ«l , South Music Luxembourg a.s.b.l.      |
    // @----------------------------------------------------------------------@
    // | Author: Olivier Noƫl <stilnoct@me.com>                               |
    // @----------------------------------------------------------------------@
    // 
    // ONAIR.php Version 1.0 30/11/2012
    // @----------------------------------------------------------------------@
    // | READ INSTALLATION INSTRUCTIONS BEFORE                                |
    // | ask it <stilnoct@me.com>                                             |
    // @----------------------------------------------------------------------@
    function saveChildren($element)
    {
    	global $elements;
    	foreach($element->children() as $child)
    	{
      		$elements[$child->getName()] = $child;
      		saveChildren($child);
    	}
    }
    function getAttribute($element, $attr)
    {
    	foreach ($element->attributes() AS $key => $attribute)
    	{
    		if ($key == $attr) return $attribute;
    	}
    }
    global $elements;
    // @----------------------------------------------------------------------@
    // | NOW ON AIR XML phath                                                 |
    // @----------------------------------------------------------------------@
    if (file_exists("onair/NowOnAir.xml"))
    {
    	$xmlstring = utf8_decode(file_get_contents("onair/NowOnAir.xml"));
    	$xmlstring = str_replace("&", "and", $xmlstring);
    	$xml = simplexml_load_string($xmlstring);
    	
    	saveChildren($xml);
    
    	foreach ($elements AS $key => $elmnt)
    	{	
    		switch ($key)
    		{
    			case "Song":
    				$actsongtitle = getAttribute($elmnt, "title");
    			break;
    		
    			case "Artist":
    				$actartistname = getAttribute($elmnt, "name");
    			break;
    		}
    	}
    	$act_onair = true;
    }
    if ($act_onair === true)
    {
    	$act_string = $actartistname." - ".$actsongtitle;
    	if ($songs[0] != $act_string)
    	{
    		$txt = $act_string."\n";
    		{
    		}
    	}
    }
    // @----------------------------------------------------------------------@
    // | HERE YOU CAN CHANGE THE TEXT : NOW ON AIR                            |
    // | COLOR STYLE ETC                                                      |
    // @----------------------------------------------------------------------@
    echo "
    <html>
    <head>
    <meta http-equiv='refresh' content='30'>
    </head>
    <body style='background-color:transparent;';>
    <div style='font-size:11; color:#AAAAAA; font-family:Verdana,Arial;'>";
    echo "<span style='font-weight:slim; color:#EC7906;'>NOW ON AIR :</span><br>".htmlentities($act_string);
    // @----------------------------------------------------------------------@
    // | NEXT ON AIR XML phath                                                |
    // @----------------------------------------------------------------------@
    if (file_exists("onair/AirPlayNext.xml"))
    {
    	$xmlstring = utf8_decode(file_get_contents("onair/AirPlayNext.xml"));
    	$xmlstring = str_replace("&", "and", $xmlstring);
    	$xml = simplexml_load_string($xmlstring);
    	
    	saveChildren($xml);
    
    	foreach ($elements AS $key => $elmnt)
    	{	
    		switch ($key)
    		{
    			case "Song":
    				$actsongtitle = getAttribute($elmnt, "title");
    			break;
    		
    			case "Artist":
    				$actartistname = getAttribute($elmnt, "name");
    			break;
    		}
    	}
    	$act_onair = true;
    }
    
    $t = file_get_contents("onair/last5.txt");
    $songs = explode("\n", $t);
    
    if ($act_onair === true)
    {
    	$act_string = $actartistname." - ".$actsongtitle;
    	if ($songs[0] != $act_string)
    	{
    		$txt = $act_string."\n";
    // @----------------------------------------------------------------------@
    // | LAST PLAYED   "for ($i=0; $i<1; $i++) = 1  SONG , 2 = 2 SONGS        |
    // @----------------------------------------------------------------------@
    		for ($i=-0; $i<7; $i++)
    		{
    			if ($songs[$i] != "") $txt .= $songs[$i]."\n";
    		}
    		file_put_contents("onair/last5.txt", $txt);
    		$t = file_get_contents("onair/last5.txt");
    		$songs = explode("\n", $t);
    	}
    }
    
    // @----------------------------------------------------------------------@
    // | HERE YOU CAN CHANGE THE TEXT : NEXT ON AIR , LAST 6 PLAYED           |
    // | COLOR STYLE ETC                                                      |
    // @----------------------------------------------------------------------@
    
    echo "
    <html>
    <head>
    <meta http-equiv='refresh' content='15'>
    </head>
    <body style='background-color:transparent;';>
    <div style='font-size:11; color:#AAAAAA; font-family:Verdana,Arial;'>";
    echo "<br><span style='font-weight:slim; color:#EC7906;'>COMING UP :</span><br>".htmlentities($act_string);
    echo "<br><br><span style='font-weight:slim; color:#EC7906;'>LAST PLAYED :</span><br>";
    $c = count($songs);
    for ($i=2; $i<$c; $i++) echo htmlentities($songs[$i])."<br>";
    // @----------------------------------------------------------------------@
    // | YOU ARE NOT PERMITTED TO REMOVE, CHANGE OR DELETE THE NEXT FILES     |
    // @----------------------------------------------------------------------@
    echo "</div>";
    echo "
    <div>";
    echo "<span style='font-weight:smal; font-size:11; font-family:Verdana,Arial;'color:#EC7906;'></span><br>";
    ?>

  • #7
    New Coder
    Join Date
    Sep 2009
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    wath i can do know somebody can help me please

  • #8
    New Coder
    Join Date
    Sep 2009
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    then the file source itself is of no use as the damage is at the storage level for the data

    wath i can do

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    You can start by adding a header for the charset as I've shown. Header must be put before any output. You'll need to correct the HTML as well; as you have it you have multiple html and body tags.

    If its damaged at the storage level, you can't do a thing to interpret it. If the storage is literally a ? within it, then that is what you get. You'll simply have to wait until the service provides you with a value that you expect accented characters within it to verify it if you cannot force it to show the one you want.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •