[swift-users] \r\n is one Character

zhaoxin肇鑫 owenzx at gmail.com
Wed Jan 27 23:23:40 CST 2016


​For a new line, Unix uses LF, Classic Mac uses  ​CR, Windows uses  CRLF.
They both means the CR in Unicode.

let str = "\r\n"

str.characters.count // 1

str.lengthOfBytesUsingEncoding(NSUTF8StringEncoding) // 2

str.unicodeScalars.first!.value // 13


zhaoxin

On Thu, Jan 28, 2016 at 11:52 AM, Darren Mo via swift-users <
swift-users at swift.org> wrote:

> "\r\n" is a single Character. Is this the correct behaviour?
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160128/b305ddb4/attachment.html>


More information about the swift-users mailing list