CharacterSet intitializer does not work properly with String consisting only of Emoji

Originator:silvan.daehn
Number:rdar://29682862 Date Originated:15-Dec-2016 03:35 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 8.0 (8A218a)
Classification:Other Bug Reproducible:Always
 
Summary:
A CharacterSet initialised with only a emoji is  empty (reported as being a subset of the alphanumerics CharacterSet).

Steps to Reproduce:
Execute the following code:

let empty = CharacterSet(charactersIn: "")
let onlyEmoji = CharacterSet(charactersIn: "🐷")
let emojiAndCharacter = CharacterSet(charactersIn: "🐷a")

empty.isSubset(of: .alphanumerics) // true
onlyEmoji.isSubset(of: .alphanumerics) // true
emojiAndCharacter.isSubset(of: .alphanumerics) // false


Expected Results:
As the Emoji is not contained in the alphanumerics (irregardless of the underlying unicode representation) it should not report to be a subset of the alphanumeric set or be empty. If it does then it should be consistent when initialised with a string containing a character and an Emoji.

Actual Results:
It reports to be a subset of the alphanumerics, but does not when initialised with an additional character.

Notes:
Provide a failable or throwing initializer that prevents this usage or change the implementation to work with Emoji.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!