Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP-Funktion zum Umwandeln von Hexadezimalen Entities in Sonderzeichen

Empfohlene Antworten

Veröffentlicht

Hi Leute,

ich schreibe gerade ein Script, das eine Datei mit dem DOM-Parser behandelt.

Dieser DOM-Parser aber speichert mir die Datei mit Hexadezimalen Entities ab, was aber absolut nicht erwünscht ist, da wir dadurch zu einem späteren Zeitpunkt Probleme bekommen.

Ich habe DOM-Parser-mäßig schon alles versucht und es nicht hinbekommen ihn in dem Punkt zu zügeln.

Gibt es nicht eine Funktion die die Hexadezimalen Entities in die Sonderzeichen (z.B. ä, ö, ü) wieder umwandelt? Mit utf8_decode habe ich es auch schon versucht....

Workarount meinerseits wäre jetzt einfach einen Array mit den Entities durch einen Array mit den Sonderzeichen zu ersetzen, aber das ist ja nicht dauerhaft konsistent... Weil sobald sich etwas an den Entities ändert, müßte ich das bei mir ja auch anpassen.

Wäre Euch für Ideen sehr dankbar! Danke schonmal im Voraus.

Grüße Hägi

Jein... Die html_entity_decode hat mir nicht das gebracht was ich wollte.

Habs aber jetzt auch gelöst bekommen (so wie es aussieht)



$content = preg_replace('~([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $content);
$content = preg_replace('~([0-9]+);~e', 'chr("\\1")', $content);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
$content = strtr($content, $trans_tbl);

[/PHP]

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.