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
Here's my implementation, it returns an array of the ASCII values.
extension String { func asciiValueOfString() -> [UInt32] { var retVal = [UInt32]() for val in self.unicodeScalars where val.isASCII() { retVal.append(UInt32(val)) } return retVal } }
Note: Yes it's Swift 2 compatible.