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.

HTML Strings encode

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

gibt es von/in Java eine Methode/Klasse zum Encoden von HTML Strings?

z.b.


& => &

ä => ä

ö => ö

ü => ü

Danke im vorraus,

Gruß,

Markus

hm das o.g. Problem hab ich mit nem anderen Character Encoding lösen können.

(ISO-8859-1)

Nun hab ich ein neues Problem.

Ich habe Länderspezifische Sonderzeichen, die sich im 16 Bit bereich befinden.

Diesen gehen ich so zu leibe:


 StringBuffer help=new StringBuffer("");

  for (int t = 0 ;t<text.length();t++) {

    if (((int) text.charAt(t))>255) {

      help.append(""+Integer.toHexString((int) text.charAt(t))+";");

      } else help.append(text.charAt(t));

  }

kann ich das noch besser/schneller lösen?

ab 1.4 (bin ich mir ziemlich sicher) gibt es im Paket

java.net die st. Klasse URLEncoder

mit der Methode URLEncoder.encode(

gruss / zirri

ab 1.4 (bin ich mir ziemlich sicher) gibt es im Paket

java.net die st. Klasse URLEncoder

mit der Methode URLEncoder.encode(

gruss / zirri

Hi,

URLEncode und HTMLEncode sind aber 2 paar Schue ;-)

URL Encode macht z.b. aus "<" ein "%3C".

HTML Encode macht z.b. aus "<" ein "<".

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

Ich glaub am schönsten wäre ein RegEx, der alle Zeichen deren wert > 255 (also mehr als 8 Bit ) groß ist, mit "&x" + HexWertDesZeichens + ";" ersetzt.

Dabei müsste darauf geachtet werden, dass z.b. " " das "&" nicht in "&x32;" übersetzt wird

Moin,

System.out.println(org.apache.commons.lang.StringEscapeUtils.escapeHtml("ä"));

http://jakarta.apache.org/commons/lang/

Gruß Jaraz

Moin,

besten dank, ich verusch mein Glück!

Gruß,

kills

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.