Documentation ¶
Index ¶
- type Encoding
- func (self Encoding) Decode(out []byte, src []byte) (int, error)
- func (self Encoding) DecodeString(s string) ([]byte, error)
- func (self Encoding) DecodeUnsafe(out *[]byte, src []byte) (int, error)
- func (self Encoding) DecodedLen(n int) int
- func (self Encoding) Encode(out []byte, src []byte)
- func (self Encoding) EncodeToString(src []byte) string
- func (self Encoding) EncodeUnsafe(out *[]byte, src []byte)
- func (self Encoding) EncodedLen(n int) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Encoding ¶
type Encoding int
An Encoding is a radix 64 encoding/decoding scheme, defined by a 64-character alphabet. The most common encoding is the "base64" encoding defined in RFC 4648 and used in MIME (RFC 2045) and PEM (RFC 1421). RFC 4648 also defines an alternate encoding, which is the standard encoding with - and _ substituted for + and /.
const JSONStdEncoding Encoding = _MODE_JSON
JSONStdEncoding is the StdEncoding and encoded as JSON string as RFC 8259.
const RawStdEncoding Encoding = _MODE_RAW
RawStdEncoding is the standard raw, unpadded base64 encoding, as defined in RFC 4648 section 3.2.
This is the same as StdEncoding but omits padding characters.
const RawURLEncoding Encoding = _MODE_RAW | _MODE_URL
RawURLEncoding is the unpadded alternate base64 encoding defined in RFC 4648. It is typically used in URLs and file names.
This is the same as URLEncoding but omits padding characters.
const URLEncoding Encoding = _MODE_URL
URLEncoding is the alternate base64 encoding defined in RFC 4648. It is typically used in URLs and file names.
func (Encoding) Decode ¶
Decode decodes src using the encoding enc. It writes at most DecodedLen(len(src)) bytes to out and returns the number of bytes written. If src contains invalid base64 data, it will return the number of bytes successfully written and base64.CorruptInputError.
New line characters (\r and \n) are ignored.
If out is not large enough to contain the encoded result, it will panic.
func (Encoding) DecodeString ¶
DecodeString returns the bytes represented by the base64 string s.
func (Encoding) DecodeUnsafe ¶
DecodeUnsafe behaves like Decode, except it does NOT check if out is large enough to contain the decoded result.
It will also update the length of out.
func (Encoding) DecodedLen ¶
DecodedLen returns the maximum length in bytes of the decoded data corresponding to n bytes of base64-encoded data.
func (Encoding) Encode ¶
Encode encodes src using the specified encoding, writing EncodedLen(len(src)) bytes to out.
The encoding pads the output to a multiple of 4 bytes, so Encode is not appropriate for use on individual blocks of a large data stream.
If out is not large enough to contain the encoded result, it will panic.
func (Encoding) EncodeToString ¶
EncodeToString returns the base64 encoding of src.
func (Encoding) EncodeUnsafe ¶
EncodeUnsafe behaves like Encode, except it does NOT check if out is large enough to contain the encoded result.
It will also update the length of out.
func (Encoding) EncodedLen ¶
EncodedLen returns the length in bytes of the base64 encoding of an input buffer of length n.