encoding.base64: fix doc comment examples

This commit is contained in:
Delyan Angelov 2025-08-13 17:59:09 +03:00
parent cf2bff504d
commit 7d08554c3c
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED

View file

@ -187,7 +187,7 @@ mut:
// decode decodes the base64 encoded `string` value passed in `data`.
// Please note: If you need to decode many strings repeatedly, take a look at `decode_in_buffer`.
// Example: assert base64.decode('ViBpbiBiYXNlIDY0') == 'V in base 64'
// Example: assert base64.decode('ViBpbiBiYXNlIDY0') == 'V in base 64'.bytes()
pub fn decode(data string) []u8 {
mut size := i64(data.len) * 3 / 4
if size <= 0 || data.len % 4 != 0 {
@ -218,7 +218,7 @@ pub fn decode_str(data string) string {
// encode encodes the `[]u8` value passed in `data` to base64.
// Please note: base64 encoding returns a `string` that is ~ 4/3 larger than the input.
// Please note: If you need to encode many strings repeatedly, take a look at `encode_in_buffer`.
// Example: assert base64.encode('V in base 64') == 'ViBpbiBiYXNlIDY0'
// Example: assert base64.encode('V in base 64'.bytes()) == 'ViBpbiBiYXNlIDY0'
pub fn encode(data []u8) string {
return alloc_and_encode(data.data, data.len)
}