<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I raised&nbsp;<a href="https://bugs.swift.org/browse/SR-337" class="">https://bugs.swift.org/browse/SR-337</a>&nbsp;to implement hasPrefix and hasSuffix in Swift (instead of depending on the Objective-C implementation and only being available for OSX at present.<div class=""><br class=""></div><div class="">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</div><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift/blob/master/stdlib/public/core/StringLegacy.swift#L98" class="">https://github.com/apple/swift/blob/master/stdlib/public/core/StringLegacy.swift#L98</a></div><div class=""><br class=""></div><div class="">inside ‘StringLegacy.swift’ but I’d presume it’s better to live elsewhere.</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">Happy to take comments by mail or on the bug.</div><div class=""><br class=""></div><div class="">Alex</div></body></html>