I have a HEX string d285 and I want to convert it UInt16, please guide me how I can convert it. I tried this
let buffer = UInt16("\(UInt8(text, radix: 16)!)")
return Data(bytes: (buffer?.bigEndian.toBytes)!)
but it's not working
I have a HEX string d285 and I want to convert it UInt16, please guide me how I can convert it. I tried this
let buffer = UInt16("\(UInt8(text, radix: 16)!)")
return Data(bytes: (buffer?.bigEndian.toBytes)!)
but it's not working
UInt16 has an initializer that takes a string and radix value. This can be used to create UInt16 from string.