Skip to content

Commit 677b2d6

Browse files
sorairolakelinusg
authored andcommitted
docs(std.base64): Add references to RFC 4648
There are multiple implementations of Base64, but `std.base64` appears to be based on RFC 4648, so we clarify that it is based on RFC 4648.
1 parent dfe0fb6 commit 677b2d6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

lib/std/base64.zig

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! Base64 encoding/decoding.
1+
//! Base64 encoding/decoding as specified by
2+
//! [RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648).
23

34
const std = @import("std.zig");
45
const assert = std.debug.assert;
@@ -24,12 +25,15 @@ pub const Codecs = struct {
2425
Decoder: Base64Decoder,
2526
};
2627

28+
/// The Base64 alphabet defined in
29+
/// [RFC 4648 section 4](https://datatracker.ietf.org/doc/html/rfc4648#section-4).
2730
pub const standard_alphabet_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".*;
2831
fn standardBase64DecoderWithIgnore(ignore: []const u8) Base64DecoderWithIgnore {
2932
return Base64DecoderWithIgnore.init(standard_alphabet_chars, '=', ignore);
3033
}
3134

32-
/// Standard Base64 codecs, with padding
35+
/// Standard Base64 codecs, with padding, as defined in
36+
/// [RFC 4648 section 4](https://datatracker.ietf.org/doc/html/rfc4648#section-4).
3337
pub const standard = Codecs{
3438
.alphabet_chars = standard_alphabet_chars,
3539
.pad_char = '=',
@@ -38,7 +42,8 @@ pub const standard = Codecs{
3842
.Decoder = Base64Decoder.init(standard_alphabet_chars, '='),
3943
};
4044

41-
/// Standard Base64 codecs, without padding
45+
/// Standard Base64 codecs, without padding, as defined in
46+
/// [RFC 4648 section 3.2](https://datatracker.ietf.org/doc/html/rfc4648#section-3.2).
4247
pub const standard_no_pad = Codecs{
4348
.alphabet_chars = standard_alphabet_chars,
4449
.pad_char = null,
@@ -47,12 +52,15 @@ pub const standard_no_pad = Codecs{
4752
.Decoder = Base64Decoder.init(standard_alphabet_chars, null),
4853
};
4954

55+
/// The URL-safe Base64 alphabet defined in
56+
/// [RFC 4648 section 5](https://datatracker.ietf.org/doc/html/rfc4648#section-5).
5057
pub const url_safe_alphabet_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".*;
5158
fn urlSafeBase64DecoderWithIgnore(ignore: []const u8) Base64DecoderWithIgnore {
5259
return Base64DecoderWithIgnore.init(url_safe_alphabet_chars, null, ignore);
5360
}
5461

55-
/// URL-safe Base64 codecs, with padding
62+
/// URL-safe Base64 codecs, with padding, as defined in
63+
/// [RFC 4648 section 5](https://datatracker.ietf.org/doc/html/rfc4648#section-5).
5664
pub const url_safe = Codecs{
5765
.alphabet_chars = url_safe_alphabet_chars,
5866
.pad_char = '=',
@@ -61,7 +69,8 @@ pub const url_safe = Codecs{
6169
.Decoder = Base64Decoder.init(url_safe_alphabet_chars, '='),
6270
};
6371

64-
/// URL-safe Base64 codecs, without padding
72+
/// URL-safe Base64 codecs, without padding, as defined in
73+
/// [RFC 4648 section 3.2](https://datatracker.ietf.org/doc/html/rfc4648#section-3.2).
6574
pub const url_safe_no_pad = Codecs{
6675
.alphabet_chars = url_safe_alphabet_chars,
6776
.pad_char = null,

0 commit comments

Comments
 (0)