“\r\n” is one Character in Swift

From the department of “how did I not realise this sooner?!”:

1> “\r”.count

$R0: Int = 1

  2> “\n”.count 

$R1: Int = 1

  3> “\r\n”.count 

$R2: Int = 1

Yes, Swift treats the two bytes “\r\n” as a single character.  This is actually super convenient a lot of the time, because it means algorithms that look for line breaks with isNewline just work, even on “Windows”-style […]

https://wadetregaskis.com/rn-is-one-character-in-swift/
“\r\n” is one Character in Swift – Wade Tregaskis