1

有没有办法让程序把我的字符串作为一个整体?我在下面列出了一个示例对于第二个示例,它不会将我的整个输入作为一个完整的字符串。hotmail.com 为蓝色(超链接),而 id = 50 被识别为字符串。我猜它的双引号。我能做些什么来解决这个问题?

例如:

1. string str = "hi";
2. string str = "http://hotmail.com/"id"=50";

我试图声明的实际代码:

string url = @"http://www.onemap.sg/advminimap/MiniMap.htm?mWidth=700&mHeight=600&searchval=&zoomLevl=7&iwt=[{""id"":2,""x"":""{0}"",""y"":""{1}"",""screenX"":undefined,""screenY"":undefined,""infoWindowText"":""{2}"",""postalCode"":""{3}"",""searchVal"":"""",""calloutWidth"":100,""calloutHeight"":100,""calloutTitle"":""{4}"",""zoomLevel"":7}, {""id"":3,""x"":""{5}"",""y"":""{6}"",""screenX"":undefined,""screenY"":undefined,""infoWindowText"":""{7}"",""postalCode"":""{8}"",""searchVal"":"""",""calloutWidth"":100,""calloutHeight"":100,""calloutTitle"":""{9}"",""zoomLevel"":7}]&check=true&calloutTitle=&calloutWidth=100&calloutHeight=100&isEdit=1&isSearch=0";
4

2 回答 2

1

始终对可能需要包含任何异常内容的 URL 部分使用 url 编码......如果您想了解标准,请参阅RFC1738

“...只有字母数字 [0-9a-zA-Z]、特殊字符 $-_.+!*'() 和用于其保留目的的保留字符可以在 URL 中未编码使用。”

要在 url 中包含双引号,您需要将其编码为 %22

于 2013-10-15T05:56:50.913 回答
-1

在引号内使用\之前:

string str = "this is \ "一些引号\ "你需要放在字符串里面";

于 2013-10-15T06:24:54.473 回答