0

I'm having an App with a NanoHTTPD-Server that allows editing notes via a browser. It displays a HTML-form that allows editing the note and sending it to the device. But if I type in äöü, it displays on the android "?" an in my browser "�".

HTML-Code:

<html>
<head><title>Notes</title></head>
<body><h1>Notes</h1><form method=POST>
<textarea name=noe cols='50' rows='10'></textarea>
<br>
<input type=submit value=save></form></body>
</html>

How do I display äöü?

Edit:

Java-Code:

    @Override
    public Response serve(String uri, Method method,
            Map<String, String> headers, Map<String, String> parms,
            Map<String, String> files) {
        Response ret = null;
        if (method == Method.GET) ret = new Response(Status.OK, MIME_HTML, getHTML());
        else if (method == Method.POST) ret = saveNote(parms);
        return ret;
    }

    private Response saveNote(Map<String, String> parms) {
        Notizen.notes = parms.get("notiz");
        osl.refresh();
        return new Response(Status.OK, MIME_HTML, getHTML());
    }

    private String getHTML()
    {
        HtmlGenerator hg = new HtmlGenerator();
        String header = hg.start+hg.getSitetitle("Notes")+hg.zwischen+hg.getTitle("Notes");
        String form = hg.getForm("POST")+hg.getInputMultiline("note", Notizen.notes)+hg.brk+hg.getSubmit("save")+hg.endform;
        String end = hg.stop;
        String site = header+form+end;
        return site;
    }

Umwandler:

public String formatTextUml (String text)
    {
        text = text.replaceAll("ä", "&auml;");
        text = text.replaceAll("Ä", "&Auml;");
        text = text.replaceAll("ö", "&ouml;");
        text = text.replaceAll("Ö", "&Ouml;");
        text = text.replaceAll("ü", "&uuml;");
        text = text.replaceAll("Ü", "&Uuml;");
        return text;
    }
Stephan
  • 41,764
  • 65
  • 238
  • 329
adnidor
  • 78
  • 9

2 Answers2

0

The "Umlaute" have to be changed into the HTML entities, which code these characters. In these cases it would be either: &Auml;, &Ouml; or &Uuml; For more specific help, post the related code please.

G_J
  • 314
  • 3
  • 6
0

There's a library to unescapeHtml : Apache commons lang

(dependencies) compile 'commons-lang:commons-lang:2.3'

import org.apache.commons.lang.StringEscapeUtils;
.
.
String withUmlaut = StringEscapeUtils.unescapeHtml(yourString);
Khalil Kitar
  • 331
  • 4
  • 8