| 351 | static const char base64EncodingTable[] = ".ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+"; |
| 352 | |
| 353 | String MemoryBlock::toBase64Encoding() const |
| 354 | { |
| 355 | auto numChars = ((size << 3) + 5) / 6; |
| 356 | |
| 357 | String destString ((unsigned int) size); // store the length, followed by a '.', and then the data. |
| 358 | auto initialLen = destString.length(); |
| 359 | destString.preallocateBytes ((size_t) initialLen * sizeof (String::CharPointerType::CharType) + 2 + numChars); |
| 360 | |
| 361 | auto d = destString.getCharPointer(); |
| 362 | d += initialLen; |
| 363 | d.write ('.'); |
| 364 | |
| 365 | for (size_t i = 0; i < numChars; ++i) |
| 366 | d.write ((juce_wchar) (uint8) base64EncodingTable[getBitRange (i * 6, 6)]); |
| 367 | |
| 368 | d.writeNull(); |
| 369 | return destString; |
| 370 | } |
| 371 | |
| 372 | static const char base64DecodingTable[] = |
| 373 | { |
no test coverage detected