Swift String表现出奇怪的转义单引号

时间:2019-04-01 14:43:20

标签: ios swift xcode

本质上,在此示例中,我需要一个String来保存值"This is John\\'s"。无论我在这里尝试使用多少XCode体操,我都无法使其表现出自己想要的样子。我只是将其保留为NSString,但是我提供给它的API需要一个String,然后将其抛弃会破坏它。见下文,我是个新主意。

(lldb) po "This is John's"
"This is John\'s"

(lldb) po "This is John\'s"
"This is John\'s"

(lldb) po "This is John\\'s"
"This is John\\\'s"

(lldb) po "This is John\\\'s"
"This is John\\\'s"

(lldb) po "This is John\\\\'s"
"This is John\\\\\'s"

(lldb) po "This is John\\\\'s" as NSString
This is John\\'s

(lldb) po ("This is John\\\\'s" as NSString) as String
"This is John\\\\\'s"

0 个答案:

没有答案