4 ms·
If you have a range of unicode code points that you want to select from, you can generate a random number in that range and then turn it into a one-character st
by mikeash 12y ago
If you have a range of unicode code points that you want to select from, you can generate a random number in that range and then turn it into a one-character string like so:
let codepoint: UInt32 = ...random choice code here...
let scalar = UnicodeScalar(codepoint)
let string = String(scalar)