Created
September 28, 2024 15:16
-
-
Save artemisia-absynthium/b71a890824bd27c1510f6ffe6a446bd2 to your computer and use it in GitHub Desktop.
Byte array pretty print
This file contains hidden or 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
import Foundation | |
extension Data { | |
func toString() -> String { | |
if let string = String(data: self, encoding: .utf8) { | |
return string | |
} else { | |
return map { String(format: "%02X", $0) }.joined() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment