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.

Convert UTF-8 String nach ANSI

Empfohlene Antworten

Hallo zusammen!

Ich google mir schon en Wolf und hab folgendes Problem:

Ich möchte gerne einen UTF-8 String nach ANSI in Java konvertieren.

Als Beipsiel habe ich einen arabischen String, welcher mit Notepad++

in UTF-8 so aussieht:

مل على مدار اليوم. يمكنك مشاهدة ب

und konvertiert in ANSI:

مل على مدار اليوم. يمكنك مشاهدة ب

Das dazugehörige Code-Snippet sieht so aus:

String content = "مل على مدار اليوم. يمكنك مشاهدة ب";

String test = new String (content.getBytes("UTF-8"),"ANSI");

(Anstelle von ANSI --> ISO-8859-1 funzt auch net)

Vielen Dank für Eure Hilfe!

Mein Code-Snippet liefert mir nicht das Ergebnis, was ich per Notepad++ getestet habe.

Was ist an meinem Code falsch?

Ist Deine Quellcodedatei in UTF-8 codiert? Ich könnte mir vorstellen, dass ansonsten der String, den Du ja hart in der Quellcodedatei angibst, in einem anderen Encoding vorliegt und es schon beim verarbeiten des Sourcestrings als UTF-8 zu Problemen kommt. Die Angabe "ANSI" habe ich noch nicht gesehen, sondern immer nur "ISO-8859-1". Wenn es aber nicht zu einer UnsupportedEncodingException kommt, scheint die VM das Encoding zu kennen.

Peter

Mein Code-Snippet liefert mir nicht das Ergebnis, was ich per Notepad++ getestet habe.
Dann solltest du uns mitteilen wie dein gewünschtes Ergebnis aussieht und was für Abweichungen es gibt.

Am besten noch einen lauffähigen Testcase dazu, mit dem man das Problem nachstellen kann.

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.