我试图将此字符串作为get参数传递。此字符串以下列字符开头:
字符串名是一些HTML基本上是一些HTML
<p style=\"-qt-block-indent: 0; text-indent: 0px; margin: 18px 0px 12px 0px;\"><span style=\"font-size: xx-large;
但是我只得到这个
<p style=\\"-qt-block-indent: 0
这就是我传递字符串的方式:
http://127.0.0.1:8000/service_SubmitResult?htmlstring=some_html
任何关于我可能做错什么的想法。我通过qt发送字符串并在django端点接收它?我相信这是因为semicolon。我在发送前使用以下函数对url进行编码
QUrl ServiceCalls::UrlFromUserInput(const QString& input)
{
QByteArray latin = input.toLatin1();
QByteArray utf8 = input.toUtf8();
if (latin != utf8)
{
// URL string containing unicode characters (no percent encoding expected)
return QUrl::fromUserInput(input);
}
else
{
// URL string containing ASCII characters only (assume possible %-encoding)
return QUrl::fromUserInput(QUrl::fromPercentEncoding(input.toLatin1()));
}
}
为什么我只收到一部分。在django上,我以如下方式获取参数值
def service_foo(request):
try:
htmlResult = request.GET.get('htmlstring', '')
....
return HttpResponse();
except Exception as e:
print(e)
return HttpResponse("Error Service from sqlite")
有什么建议可以解决这个问题,或者我可以使用什么其他选项?
最佳答案
我想你必须在发送之前把字符串,html转义
在qt中有一些方法可以做到这一点。
看看this问题。