ich versuche meiner Artikle List advance folgendes beizubringen.
In der Headline sollen Umlaute wieder als AE, OE, UE ausgegeben werden, Leerzeichen als Unterstrich usw.
Ich habe versucht mit der Funktion etwas zu machen:
Code: Alles auswählen
function capiStrReplaceDiacritics ($sString, $sourceEncoding = "ISO-8859-1", $targetEncoding = false)
{
/* If the target encoding isn't set, use source encoding */
if ($targetEncoding == false)
{
$targetEncoding = $sourceEncoding;
}
// replace regular german umlauts and other common characters with diacritics
static $aSearch, $aReplace;
if (!isset($aSearch)) {
$aSearch = array('Ä', 'Ö', 'Ü', 'ä', 'ö', 'ü', 'ß', 'Á', 'À', 'Â', 'á', 'à', 'â', 'É', 'È', 'Ê', 'é', 'è', 'ê', 'Í', 'Ì', 'Î', 'í', 'ì', 'î', 'Ó', 'Ò', 'Ô', 'ó', 'ò', 'ô', 'Ú', 'Ù', 'Û', 'ú', 'ù', 'û');
$aReplace = array('Ae', 'Oe', 'Ue', 'ae', 'oe', 'ue', 'ss', 'A', 'A', 'A', 'a', 'a', 'a', 'E', 'E', 'E', 'e', 'e', 'e', 'I', 'I', 'I', 'i', 'i', 'i', 'O', 'O', 'O', 'o', 'o', 'o', 'U', 'U', 'U', 'u', 'u', 'u');
}
$sString = str_replace($aSearch, $aReplace, $sString);
/* TODO: Additional converting */
return ($sString);
}
Code: Alles auswählen
$sTmpValue = html_entity_decode(strip_tags(urldecode($db2->f('headline'))));
if ($aSettings["HeadlineLength"] > 0 && strlen($sTmpValue) > $aSettings["HeadlineLength"]) {
# Cutting text but preserving words and entities
$sTmpValue = capiStrTrimAfterWord($sTmpValue, $aSettings["HeadlineLength"])."...";
}
$aData[$i]["Headline"] = $sTmpValue;
Vielen Dank schon mal!