What's the simplest way to convert from a single character String to an ASCII value in Swift?

后端 未结 14 1299
陌清茗
陌清茗 2020-11-29 01:00

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         


        
14条回答
  •  庸人自扰
    2020-11-29 01:38

    Now in Xcode 7.1 and Swift 2.1

    var singleChar = "a"
    
    singleChar.unicodeScalars.first?.value
    

提交回复
热议问题