yoni
1
Hi,
I'm pretty new to Swift, so I might be completely off, but I find this behaviour surprising/buggy(?):
let str = "bar"
if str.range(of: "r\u{0}")!.upperBound > str.endIndex {
print("Weird!")
}
I'd expect this range() to not match, and also the result of String.range() to never exceed the string's boundaries.
Am I off or is this a bug?
Thanks!
SDGGiesbrecht
(Jeremy David Giesbrecht)
2
I think this is one for bugs.swift.org.
Martin
(Martin R)
4
Could this be related to the recent change that strings are internally stored as a nul-terminated UTF-8 sequence?
xwu
(Xiaodi Wu)
5
Since range(of:) is a Foundation API, you're likely better off filing a bug using Feedback Assistant.
1 Like