I'm writing a routine in Swift that needs to try to convert an arbitrary integer to a UnicodeScalar or return an error. The constructor UnicodeScalar(_:Int)
does the job for valid code points, but it crashes when passed integers that are not valid code points.
Is there a Swift (or Foundation) function I can call to pre-flight that an integer i
is a valid Unicode code point and won't cause UnicodeScalar(i)
to crash?