Created
March 16, 2021 05:36
-
-
Save ha1f/d2ec69acc92c079dbe0b8b5fd5b1ee25 to your computer and use it in GitHub Desktop.
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
private func _hexString<I: BinaryInteger>(_ value: I) -> String { | |
"0x" + String(value, radix: 16) | |
} | |
extension Character { | |
func hexRepresentation() -> String { | |
unicodeScalars | |
.map { _hexString($0.value) } | |
.joined(separator: ", ") | |
} | |
} | |
extension StringProtocol { | |
func hexRepresentation() -> String { | |
unicodeScalars | |
.map { _hexString($0.value) } | |
.joined(separator: ", ") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment