bonjour a tous , petit problème d'accent avec le plug Prévisions météo de J. Nielsen.
Nuit l\u00e9g\u00e8rement voil\u00e9e au lieu de nuit légèrement voilée...
une idée pour corriger le problème ?
merci à tous .
benj70b a écrit:utiliser utf8_decode dans le script
function sdk_Tjson($url){
$json = httpQuery($url);
$json = sdk_u8toa($json);
$Tjson = sdk_json_decode($json, false);
return $Tjson;
}
function sdk_u8toa($valor)
{
$u8toa = array(
"\u00e0" => "à",
"\u00e2" => "â",
"\u00e4" => "ä",
"\u00e7" => "ç",
"\u00e8" => "è",
"\u00e9" => "é",
"\u00ea" => "ê",
"\u00eb" => "ë",
"\u00ee" => "î",
"\u00ef" => "ï",
"\u00f4" => "ô",
"\u00f6" => "ö",
"\u00f9" => "ù",
"\u00fb" => "û",
"\u00fc" => "ü",
"\u0080" => "°");
return strtr($valor, $u8toa);
}
}
benj70b a écrit:avec utf8_decode ca fonctionne pas, voici un contournement en remplacant sdk_Tjson:
- Code : Tout sélectionner
function sdk_Tjson($url){
$json = httpQuery($url);
$json = sdk_u8toa($json);
$Tjson = sdk_json_decode($json, false);
return $Tjson;
}
function sdk_u8toa($valor)
{
$u8toa = array(
"\u00e0" => "à",
"\u00e2" => "â",
"\u00e4" => "ä",
"\u00e7" => "ç",
"\u00e8" => "è",
"\u00e9" => "é",
"\u00ea" => "ê",
"\u00eb" => "ë",
"\u00ee" => "î",
"\u00ef" => "ï",
"\u00f4" => "ô",
"\u00f6" => "ö",
"\u00f9" => "ù",
"\u00fb" => "û",
"\u00fc" => "ü",
"\u0080" => "°");
return strtr($valor, $u8toa);
}
}
PS : j'ai mis a jour le plugin en version 1.1 pour intégrer cette correction.
dommarion a écrit:Bonjour à tous,
Le Plugin previsions-météo est HS...
"Site en maintenance
Notre site est actuellement en maintenance pour une durée indéterminée. Merci de réessayer plus tard.
L'équipe prevision-meteo.ch"
dommarion
http://localhost/script/?exec=bulletin.php&zone=[VAR1]
<?php
// http://localhost/script/?exec=bulletin.php&zone=[VAR1]
// VAR: run, be et fr par défaut - //bulletin
$zone= getArg('zone');
if ($zone == "run") {
$url = "http://www.meteofrance.re/previsions-meteo-reunion/bulletin";
$url = httpQuery($url,'GET');
preg_match_all('#<div class="mod-body">\s*<div class="article-row">\s*<h2>.*</h2>\s*<p class="p-style-2" style="clear: both;">(?:<br/>)+(.*?)(?:<br/>)+#',$url,$matches);
$url = strtolower($matches[1][0]);
} elseif ($zone == "be") {
$url = "https://www.meteo.be/fr/belgique";
$url = httpQuery($url,'GET');
preg_match_all('~; float: left; vertical-align: middle;;"></div>(.*?)</div><~',$url,$matches);
$url = strtolower($matches[1][0]);
} else {
$url = "http://www.meteofrance.com";
$url = httpQuery($url,'GET');
preg_match_all('~class="teaser_article teaser_article_1" title="(.*?)">.*<figure>~s',$url,$matches);
$url = strtolower($matches[1][0]);
}
$url=utf8_decode($url);
// supprime
$p = array("même type de temps,","encore","du département","que les jours précédents","..");
$s = array("","","","","");
// change
$o = array(".","nord","sud","ouest","est",", et","encore"," et ","des pyrénées","des alpes","« orages »");
$r = array(",","N","S","O","E",",","",", ","pyrénéen","alpin","orages");
$o = array_merge($p,$o);
$r = array_merge($s,$r);
// rétablit
$p = array("Eival","rEe","E étendue");
$s = array("estival","reste","est étendue");
$o = array_merge($o,$p);
$r = array_merge($r,$s);
$url = str_replace($o, $r, $url);
// contracte rdv
$url = preg_replace ("#([NSEO])-([NSEO])-?([EO])?#","$1$2$3",trim($url));
$url = preg_replace ("/,$/", ".", $url);
$url = strtoupper($url[0]) . substr($url, 1);
$url = "<bulletin>" . $url . "</bulletin>";
echo $url;
?>
Retour vers Scripts & Périphériques du store
Utilisateurs parcourant ce forum : Google [Bot] et 19 invité(s)