Swift – Double Quotes inside String

To include quotes inside a string in Swift, escape the quotes with backslash character.

Example

In the following program, we initialized a variable with String value containing double quote. We have escaped the double quote with a backslash character.

main.swift

import Foundation

var name = "Hello \"World"
print(name)

Output

Hello "World

Conclusion

In this Swift Tutorial, we learned how to include double quotes inside a String value in Swift, with the help of example programs.