Backspace(\b)快速语言中的等效项 [英] Backspace (\b) Equivalent in swift language

查看:85
本文介绍了Backspace(\b)快速语言中的等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

\b 的等价货币是多少?我必须使用 \b 拆分从服务器收到的字符串吗?

What is the \b equivalent in swift? I have to split a string which is received from server with \b?

推荐答案

来自字符串和字符 在Swift
参考中:

From "Strings and Characters" in the Swift Reference:


字符串文字中的特殊字符

Special Characters in String Literals

字符串文字中可以包含以下特殊字符:

String literals can include the following special characters:


  • 转义的特殊字符 \0 (空字符), \\ (反斜杠), \t
    (水平标签), \n (换行), \r (回车), \ (双倍
    报价)和 \ '(单引号)

  • 任意Unicode标量,写为
    \u {n} ,其中n是1–8位数的十六进制数字,其值等于
    a有效的Unicode代码点

  • The escaped special characters \0 (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}

So Swift does not have a special character for the backspace character, like \b in the C language. You can use the Unicode special character \u{n}:

let string = "THIS\u{8}IS\u{8}A\u{8}TEST"

或根据Unicode值创建字符串:

or create a string from the Unicode value:

let bs = String(UnicodeScalar(8))
let string = "THIS\(bs)IS\(bs)A\(bs)TEST"

这篇关于Backspace(\b)快速语言中的等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆