0

我有一个 std::string 文字,双引号内有双引号,双引号内。我需要使用什么格式才能使其工作?这是一个例子:

std:string http_command = "wget --post-data="user=bla password=bla query=select * from bla bla where username="" and name=bla\" http:://example.com"

以下部分失败username=""

多谢你们。

更新:修复了我的样本,我在那里多了一个双引号。

4

2 回答 2

3
std::string http_command = "wget --post-data=\"user=bla password=bla query=\"select * from bla bla where username=\"\" and name=bla\" http:://example.com"

转义除第一个和最后一个引号(分隔字符串的引号)以外的所有引号。

于 2012-10-01T12:08:00.573 回答
0
std:string http_command = "wget --post-data=\"user=bla password=bla query=\\\"select * from bla bla where username=\\\\\\"\\\\\\" and name=bla\\\" \" http:://example.com"

有点猜测,但我认为你必须逃避内部反斜杠。请注意,我认为您在帖子数据的末尾缺少报价。

于 2012-10-01T12:14:20.817 回答