退格键 (\b) 等同于 swift 语言
Backspace (\b) Equivalent in swift language
swift 中的 \b
是什么?我必须用 \b
拆分从服务器接收到的字符串?
来自 "Strings and Characters" 在 Swift
参考:
Special Characters in String Literals
String literals can include the following special characters:
- The escaped special characters
[=12=]
(null character), \
(backslash), \t
(horizontal tab), \n
(line feed), \r
(carriage return), \"
(double
quote) and \'
(single quote)
- An arbitrary Unicode scalar, written as
\u{n}
, where n is a 1–8 digit hexadecimal number with a value equal to
a valid Unicode code point
所以Swift没有退格的特殊字符
字符,如C语言中的\b
。您可以使用 Unicode
特殊字符 \u{n}
:
let string = "THIS\u{8}IS\u{8}A\u{8}TEST"
或从 Unicode 值创建一个字符串:
let bs = String(UnicodeScalar(8))
let string = "THIS\(bs)IS\(bs)A\(bs)TEST"
swift 中的 \b
是什么?我必须用 \b
拆分从服务器接收到的字符串?
来自 "Strings and Characters" 在 Swift 参考:
Special Characters in String Literals
String literals can include the following special characters:
- The escaped special characters
[=12=]
(null character),\
(backslash),\t
(horizontal tab),\n
(line feed),\r
(carriage return),\"
(double quote) and\'
(single quote)- An arbitrary Unicode scalar, written as
\u{n}
, where n is a 1–8 digit hexadecimal number with a value equal to a valid Unicode code point
所以Swift没有退格的特殊字符
字符,如C语言中的\b
。您可以使用 Unicode
特殊字符 \u{n}
:
let string = "THIS\u{8}IS\u{8}A\u{8}TEST"
或从 Unicode 值创建一个字符串:
let bs = String(UnicodeScalar(8))
let string = "THIS\(bs)IS\(bs)A\(bs)TEST"