[英]C++ std::string how to format String literal with multiple double quotes?
I have a std::string literal with double quotes inside double quotes, inside double quotes. 我有一个std :: string文字,在双引号内,双引号内有双引号。 What format do I need to use to make it work?
我需要使用什么格式才能使其正常工作? Here is an example:
这是一个例子:
std:string http_command = "wget --post-data="user=bla password=bla query=select * from bla bla where username="" and name=bla\" http:://example.com"
The following part is failing username=""
以下部分失败了
username=""
Thanks guys. 多谢你们。
Update: Fixed my sample, I had one extra double quote there. 更新:修正了我的示例,在那里我又加了一个双引号。
std::string http_command = "wget --post-data=\"user=bla password=bla query=\"select * from bla bla where username=\"\" and name=bla\" http:://example.com"
转义除第一个和最后一个(界定您的字符串的那些)之外的所有引号。
std:string http_command = "wget --post-data=\"user=bla password=bla query=\\\"select * from bla bla where username=\\\\\\"\\\\\\" and name=bla\\\" \" http:://example.com"
A bit of a guess, but I think that you have to escape the internal backslahes. 有点猜测,但是我认为您必须逃避内部的后退。 Note that I think you were missing a quote at the end of the post data.
请注意,我认为您在帖子数据末尾缺少引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.