31 static_assert(TOutCount >= TInCount,
"Decoded buffer must be larger than encoded buffer.");
33 s32 processCount = TInCount;
34 if (encoded[TInCount - 1] ==
'\0') {
38 char buffer[TInCount + 4] = { 0 };
40 for (s32 i = 0; i < processCount; i++) {
41 buffer[i] = cCharMap[
static_cast<u8>(encoded[i])];
43 buffer[processCount] =
'\0';
46 for (s32 i = 0; i < processCount; i++) {
47 if (buffer[i] ==
'\0')
50 if (buffer[i] ==
'_' && buffer[i + 1] ==
'_') {
51 if (buffer[i + 2] ==
'_') {
52 if (buffer[i + 3] ==
'_') {
53 decoded[newCharCount++] =
':';
56 decoded[newCharCount++] =
'.';
60 decoded[newCharCount++] =
'/';
64 decoded[newCharCount++] = buffer[i];
68 decoded[newCharCount] =
'\0';
80 for (s32 i = 0; i < charCount; i++) {
81 const s32 startBit = i * 6;
82 const s32 byte0 = startBit / 8;
83 const s32 offset = startBit % 8;
86 decoded[i] = (bitstream[byte0] >> (2 - offset)) & 0x3F;
88 const s32 bitsFromByte0 = 8 - offset;
89 decoded[i] = ((bitstream[byte0] & ((1 << bitsFromByte0) - 1)) << (offset - 2)) | (bitstream[byte0 + 1] >> (10 - offset));
93 decoded[charCount] =
'\0';