我有一个带有NanoHTTPD服务器的应用程序,允许通过浏览器编辑笔记。它显示一个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;
}
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;
}
答案 0 :(得分:0)
必须将“Umlaute”更改为HTML实体,这些实体会对这些字符进行编码。在这些情况下,它可以是:Ä
,Ö
或Ü
如需更具体的帮助,请发布相关代码。
答案 1 :(得分:0)
unescapeHtml有一个图书馆:Apache commons lang
from pebble import process, TimeoutError
with process.Pool() as pool:
task = pool.schedule(function, args=[1,2], timeout=5)
try:
result = task.get()
except TimeoutError:
print "Task: %s took more than 5 seconds to complete" % task
(dependencies) compile 'commons-lang:commons-lang:2.3'