In Swift how to obtain the "invisible" escape characters in a string variable into another variable -


in swift can create string variable such this:

let s = "hello\nmy name jack!" 

and if use s, output be:

hello name jack! 

(because \n linefeed)

but if want programmatically obtain raw characters in s variable? in if want like:

let sraw = s.raw 

i made .raw up, this. literal value of sraw be:

hello\nmy name jack! 

and literally print string, complete literal "\n"

thank you!

the newline "raw character" contained in string.

how formed string (in case string literal escape sequence in source code) not retained (it available in source code, not preserved in resulting program). same if read file, database, concatenation of multiple literals, multi-line literal, numeric escape sequence, etc.

if want print newline \n have convert (by doing text replacement) -- again, don't know if string created such literal.