我有一個NanoHTTPD服務器的應用程序,允許通過瀏覽器編輯註釋。它顯示一個HTML表格,允許編輯該筆記並將其發送到設備。但是如果我輸入äöü,它會顯示在android「?」上在我的瀏覽器中「�」。Android http服務器和德語「Umlaute」帖子
的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>
如何顯示AOU?
編輯:
的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;
}
Umwandler:
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;
}
難道沒人知道答案嗎? – adnidor
你是否用UTF-8提供你的html? – orique
我不知道,我沒有指定字符集 – adnidor