我有一个带有 NanoHTTPD-Server 的应用程序,它允许通过浏览器编辑笔记。它显示一个 HTML 表单,允许编辑便笺并将其发送到设备。但是如果我输入äöü,它会显示在android“?” 在我的浏览器中“�”。
HTML代码:
<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>
如何显示äöü?
编辑:
Java代码:
@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;
}
使用者:
public String formatTextUml (String text)
{
text = text.replaceAll("ä", "ä");
text = text.replaceAll("Ä", "Ä");
text = text.replaceAll("ö", "ö");
text = text.replaceAll("Ö", "Ö");
text = text.replaceAll("ü", "ü");
text = text.replaceAll("Ü", "Ü");
return text;
}