gpt4 book ai didi

ios - Backspace (\b) 在swift语言中等价

转载 作者:行者123 更新时间:2023-11-28 09:36:31 33 4
gpt4 key购买 nike

swift 中的 \b 是什么?我必须使用 \b 拆分从服务器接收到的字符串?

最佳答案

来自 "Strings and Characters"在 swift 引用:

Special Characters in String Literals

String literals can include the following special characters:

  • 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}:

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"

关于ios - Backspace (\b) 在swift语言中等价,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39042489/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com