I just want to get the ASCII value of a single char string in Swift. This is how I\'m currently doing it:
var singleChar = \"a\"
println(singleChar.unicodeSc
With Swift 5, you can pick one of the following approaches in order to get the ASCII numeric representation of a character.
Character's asciiValue propertyCharacter has a property called asciiValue. asciiValue has the following declaration:
var asciiValue: UInt8? { get }
The ASCII encoding value of this character, if it is an ASCII character.
The following Playground sample codes show how to use asciiValue in order to get
the ASCII encoding value of a character:
let character: Character = "a"
print(character.asciiValue) //prints: Optional(97)
let string = "a"
print(string.first?.asciiValue) //prints: Optional(97)
let character: Character = "