Last active
April 3, 2019 22:33
-
-
Save marcgeld/82dad51721df7938d185e2ad5bbfe26e to your computer and use it in GitHub Desktop.
make a hex String from a UInt8 collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Array of [UInt8] to hex String extension | |
// let arr = [0x03, 0x00, 0x02, 0x05, 0x11, 0x25, 0xa0, 0xfe, 0xe5] as [UInt8] | |
// let hex = arr.hexValueString (hex is the result) | |
extension Collection where Element == UInt8 { | |
var hexValueString: String { | |
return map{ String(format: "0x%02x", $0) }.joined(separator: ", ") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment