Extended String Delimiters style string not parsed by Xcode

I just read up on "Swift String Extended Delimiters" - I want to use #" and "# to enclose a String constant.

What I need is a single quote, so thought I'd use #"""# - but Xcode goes nuts and says its an unterminated string.

If I add a space: #" ""#, then all is well.

Is my String above legal syntax?

Seems like it got confused with the multi-line string head ("""). Whether it should or not, I guess you can use regular string instead "\"". It's slightly shorter as well.

To note, normally, that'd be how you change the delimiter:

let a = #"This contains ""# // This contains "

1 Like

The characters #""" mark the beginning of a multi-line raw string.

You should actually see two errors: the “Unterminated string literal” that you mentioned (because there is no matching """#) and also “Multi-line string literal content must begin on a new line” (because there is a # character after the opening delimiter #""").


Totally forgot about multiline one :flushed:.

I knew I could use """ - I was just experimenting with the "improved" syntax and mystified at the error.

Even though Nevin gave me a reason, I still this as a parsing error. My syntax is correct. That string of characters could not be a legal multi-line indicator because of the trailing "#"

However, I seriously doubt anyone is going to want to spend any time to fix it, and since I am not capable of doing that I'm going to move on! I do appreciate your comment - thanks!

You should file a bug report, for reference. It’s unclear whether there is a possible resolution— maybe the fix lies in documentation.

Missed your note, but finally did enter a bug report: