mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-11 05:26:24 +02:00
Move native/util, native/data and native/i18 to Common/Data.
Also move colorutil.cpp/h linking build fix experiment Delete a bunch of unused CMakeLists.txt files CMakeLists.txt linking fix Don't include NativeApp.h from any headers. Android.mk buildfix Half of the UWP fix Buildfix Minor project file cleanup Buildfixes Guess what? More buildfixes!
This commit is contained in:
1 parent
5c9b7bb859
commit
ff8148dd92
191 files changed
+583
-797
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#include "Common/Data/Encoding/Base64.h"
|
||||
|
||||
// TODO: This is a simple but not very efficient implementation.
|
||||
std::string Base64Encode(const uint8_t *p, size_t sz) {
|
||||
const char digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
size_t unpaddedLength = (4 * sz + 2) / 3;
|
||||
std::string result;
|
||||
result.resize((unpaddedLength + 3) & ~3, '=');
|
||||
|
||||
for (size_t i = 0; i < unpaddedLength; ++i) {
|
||||
// This is the index into the original string.
|
||||
size_t pos = (i * 3) / 4;
|
||||
int8_t off = 2 * ((i * 3) % 4);
|
||||
|
||||
int c = p[pos];
|
||||
if (off > 2) {
|
||||
c <<= 8;
|
||||
off -= 8;
|
||||
|
||||
// Grab more bits from the next character.
|
||||
if (pos + 1 < sz) {
|
||||
c |= p[pos + 1];
|
||||
}
|
||||
}
|
||||
|
||||
// Since we take from the big end, off starts at 2 and goes down.
|
||||
int8_t shift = 2 - off;
|
||||
|
||||
// Now take the bits at off and encode the character.
|
||||
result[i] = digits[(c >> shift) & 0x3F];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in new issue
Block a user