File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,8 @@ extension Base64 {
23
23
-> String where Buffer. Element == UInt8
24
24
{
25
25
// In Base64, 3 bytes become 4 output characters, and we pad to the
26
- // nearest multiple of four. We need an additional byte to create a
27
- // null-terminated UTF-8 String in the end.
28
- let newCapacity = ( ( bytes. count + 2 ) / 3 ) * 4 + 1
26
+ // nearest multiple of four.
27
+ let newCapacity = ( ( bytes. count + 2 ) / 3 ) * 4
29
28
let alphabet = options. contains ( . base64UrlAlphabet)
30
29
? Base64 . encodeBase64Url
31
30
: Base64 . encodeBase64
@@ -49,12 +48,8 @@ extension Base64 {
49
48
outputBytes. append ( thirdChar)
50
49
outputBytes. append ( forthChar)
51
50
}
52
-
53
- outputBytes. append ( 0 )
54
51
55
- return outputBytes. withUnsafeBufferPointer { ( ptr) -> String in
56
- return String ( cString: ptr. baseAddress!)
57
- }
52
+ return String ( decoding: outputBytes, as: Unicode . UTF8. self)
58
53
}
59
54
60
55
// MARK: Internal
You can’t perform that action at this time.
0 commit comments