Last active
February 11, 2017 01:40
-
-
Save erica/999dabc1a2d176bce3ec to your computer and use it in GitHub Desktop.
Composed character count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
var composedCount : Int { | |
var count = 0 | |
enumerateSubstringsInRange(startIndex..<endIndex, options: .ByComposedCharacterSequences) {_ in count++} | |
return count | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Swift 3 version: