Skip to content

Instantly share code, notes, and snippets.

@GrantJEmerson
Created November 24, 2019 00:30
Show Gist options
  • Save GrantJEmerson/c81eeb8f2a1eedc0277303f777b88877 to your computer and use it in GitHub Desktop.
Save GrantJEmerson/c81eeb8f2a1eedc0277303f777b88877 to your computer and use it in GitHub Desktop.
Same String, Different Diacritics - SwiftMoji Entry #7
import Foundation
struct πŸ‘€ {
var name: String
var comparisonName: String {
name.folding(options: [.diacriticInsensitive, .widthInsensitive, .caseInsensitive],
locale: .current)
}
}
var πŸ‘¨β€πŸ’» = πŸ‘€(name: "Sean")
var πŸ‘¨β€πŸŒΎ = πŸ‘€(name: "seΓ‘n")
if πŸ‘¨β€πŸ’».comparisonName == πŸ‘¨β€πŸŒΎ.comparisonName {
print("πŸ‘¨β€πŸ’» and πŸ‘¨β€πŸŒΎ have the same name.") // βœ…
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment