MCPcopy Create free account
hub / github.com/IoLanguage/io / UArray_asBase64

Function UArray_asBase64

libs/basekit/source/UArray_string.c:511–538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509}
510
511UArray *UArray_asBase64(const UArray *self, int charsPerLine) {
512 base64_encodestate state;
513 size_t unencodedBytesSize;
514 uint8_t *encodedBytes;
515 size_t encodedBytesSize;
516 UArray *encoded;
517
518 base64_init_encodestate(&state);
519 state.chars_per_line = charsPerLine;
520
521 unencodedBytesSize = UArray_sizeInBytes(self);
522 encodedBytes = io_calloc(2 * unencodedBytesSize, 1);
523
524 encoded = UArray_new();
525 UArray_setItemType_(encoded, CTYPE_uint8_t);
526
527 encodedBytesSize =
528 base64_encode_block((char *)UArray_bytes(self), (int)unencodedBytesSize,
529 (char *)encodedBytes, &state);
530 UArray_appendBytes_size_(encoded, encodedBytes, encodedBytesSize);
531
532 encodedBytesSize = base64_encode_blockend((char *)encodedBytes, &state);
533 UArray_appendBytes_size_(encoded, encodedBytes, encodedBytesSize);
534
535 io_free(encodedBytes);
536
537 return encoded;
538}
539
540UArray *UArray_fromBase64(const UArray *self) {
541 base64_decodestate state;

Callers 1

IoSeq_immutable.cFile · 0.85

Calls 9

base64_init_encodestateFunction · 0.85
UArray_sizeInBytesFunction · 0.85
UArray_newFunction · 0.85
UArray_setItemType_Function · 0.85
base64_encode_blockFunction · 0.85
UArray_bytesFunction · 0.85
UArray_appendBytes_size_Function · 0.85
base64_encode_blockendFunction · 0.85
io_freeFunction · 0.85

Tested by

no test coverage detected