简体   繁体   中英

Check if Unicode Character is Defined in Swift

I have a question in regards to if it would be possible to check if a character is defined in iOS unicode for example.

print(Character(UnicodeScalar(9966)))
      //this prints [?]
print(Character(UnicodeScalar(9955)))
      //this also prints [?]

Would there be a way to check if this default character is printed? Or in other words, detect that the character is not defined and will thereby print [?] .

You would have to take into consideration the font that your terminal emulator is using and whether or not the unicode character is represented in that font or in that font's fallback chain. You might be able to do this for the particular font that you are using in your terminal emulator program but that is not a general solution as someone else may be using a different font for their terminal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM