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 {
2323 -> String where Buffer. Element == UInt8
2424 {
2525 // 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
2928 let alphabet = options. contains ( . base64UrlAlphabet)
3029 ? Base64 . encodeBase64Url
3130 : Base64 . encodeBase64
@@ -49,12 +48,8 @@ extension Base64 {
4948 outputBytes. append ( thirdChar)
5049 outputBytes. append ( forthChar)
5150 }
52-
53- outputBytes. append ( 0 )
5451
55- return outputBytes. withUnsafeBufferPointer { ( ptr) -> String in
56- return String ( cString: ptr. baseAddress!)
57- }
52+ return String ( decoding: outputBytes, as: Unicode . UTF8. self)
5853 }
5954
6055 // MARK: Internal
You can’t perform that action at this time.
0 commit comments