Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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