
안녕하세요!
오늘은 백준의 10172번 개, 10171 고양이, 25083 새싹을 풀다가 알게된 String Literal의 다양한 기능들에 대해 알아보겠습니다!🐶🐈🌱
\n 사용하지 않고 그대로 쓰고 싶을 때let quotation = """
The White Rabbit put on his spectacles. "Where shall I begin,
please your Majesty?" he asked.
"Begin at the beginning," the King said gravely, "and go on
till you come to the end; then stop."
"""
\n 을 사용하면 줄 바꿈이 반영되어 출력됨let softWrappedQuotation = """
The White Rabbit put on his spectacles. "Where shall I begin, \n
please your Majesty?" he asked.
"Begin at the beginning," the King said gravely, "and go on \n
till you come to the end; then stop."
"""

\ 로 구분하기! (출력값에는 줄바꿈이 반영되지 않음!)let softWrappedQuotation = """
The White Rabbit put on his spectacles. "Where shall I begin, \
please your Majesty?" he asked.
"Begin at the beginning," the King said gravely, "and go on \
till you come to the end; then stop."
"""
출력을 보면 \ 는 무시되는 것을 확인할 수 있음


let lineWithIndentation = """
closing quotation marks에 맞춰서 시작하니까 공백 없음
이건 공백 있음
여기부터 시작이니까 이건 공백 없음
"""

\를 붙여서 사용(아래와 같은 형태를 escaped speical character라고 부름)
\0(null character),\\(backslash)\t (horizontal tab)\n(line feed)\r(carriage return)\"(double quotation mark)\'(single quotation mark)let wiseWords = "\"Imagination is more important than knowledge\" - Einstein"

\u{유니코드 스칼라 값} 으로 문자를 표현할 수도 있음 (유니코드 스칼라 값은 1-8 digit hexadecimal number)let dollarSign = "\u{24}" // $, Unicode scalar U+0024
let blackHeart = "\u{2665}" // ♥, Unicode scalar U+2665
let sparklingHeart = "\u{1F496}" // 💖, Unicode scalar U+1F496
\ 없이 그냥 사용 할 수 있음let threeDoubleQuotationMarks = """
Escaping the first quotation mark \"""
Escaping all three quotation marks \"\"\"
"""

\특수문자)를 string literal로 쓸 수 있음"에 # 을 붙이면 됨let extendedStringDelimiter = #"Line 1\nLine 2"#

"""에 #을 붙이면 됨let extenedStringDelimiter = #"""
extenedStringDelimiter에서는 \는 의미 없다, \n \t \\
"""#

let threeMoreDoubleQuotationMarks = #"""
Here are three more double quotes: """
"""#

let extenedStringDelimiter = #"""
|\_/|
|q p| /}
( 0 )"""\
|"^"` |
||_/=\\__|
"""#
출처: 백준 [https://www.acmicpc.net/problem/10172](https://www.acmicpc.net/problem/10172) (String Literal 공부의 시발 지점)

\뒤에 #을 붙여주면 됨# 개수는 통일해야함let extendedStringDelimiter = #"Line 1\#nLine 2"#
let extendedStringDelimiter = ###"Line1\###nLine2"###
동일한 결과 출력됨

https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html