I raised https://bugs.swift.org/browse/SR-337
<https://bugs.swift.org/browse/SR-337> to implement hasPrefix and hasSuffix in
Swift (instead of depending on the Objective-C implementation and only being
available for OSX at present.
I have an implementation which I’d like to create a pull request for but don’t
know where it should go. The current implementation is at
https://github.com/apple/swift/blob/master/stdlib/public/core/StringLegacy.swift#L98
<https://github.com/apple/swift/blob/master/stdlib/public/core/StringLegacy.swift#L98>
inside ‘StringLegacy.swift’ but I’d presume it’s better to live elsewhere.
In addition this uses the character view which I’m not sure follows the
normalisation required for comparisons; or if there is some different
normalisation routines that need to be written either.
Finally it’s not clear if this the right way to solve the problem, or if the
implementation should be in the open-source version of the Foundation NSString
implementation.
Happy to take comments by mail or on the bug.
Alex
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev