tangled
alpha
login
or
join now
khanwinter.com
/
CBOR
2
fork
atom
A fast, safe, and efficient CBOR serialization library for Swift on any platform.
swiftpackageindex.com/thecoolwinter/CBOR/1.1.1/documentation/cbor
atproto
swift
cbor
2
fork
atom
overview
issues
pulls
pipelines
Maybe fix test extension on linux
Khan Winter
6 months ago
051fd937
7dccdf34
+8
-1
1 changed file
expand all
collapse all
unified
split
Tests
CBORTests
Extensions
Data+hexString.swift
+8
-1
Tests/CBORTests/Extensions/Data+hexString.swift
···
12
#endif
13
14
extension Data {
0
0
15
func hexString() -> String {
16
-
map { String(format: "%02hhX", $0) }.joined()
0
0
0
0
0
17
}
18
}
···
12
#endif
13
14
extension Data {
15
+
private static let hexAlphabet = Array("0123456789abcdef".unicodeScalars)
16
+
17
func hexString() -> String {
18
+
// I'd rather use: map { String(format: "%02hhX", $0) }.joined()
19
+
// but that doesn't compile on linux...
20
+
String(reduce(into: "".unicodeScalars) { result, value in
21
+
result.append(Self.hexAlphabet[Int(value / 0x10)])
22
+
result.append(Self.hexAlphabet[Int(value % 0x10)])
23
+
})
24
}
25
}