diff --git a/src/Utils.c b/src/Utils.c index d9b5f4f65..84906ea57 100644 --- a/src/Utils.c +++ b/src/Utils.c @@ -154,8 +154,10 @@ static const char base64_table[64] = { 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' }; -int Convert_ToBase64(const cc_uint8* src, int len, char* dst) { +int Convert_ToBase64(const void* data, int len, char* dst) { + const cc_uint8* src = (const cc_uint8*)data; char* beg = dst; + /* 3 bytes to 4 chars */ for (; len >= 3; len -= 3, src += 3) { *dst++ = base64_table[ (src[0] >> 2)]; diff --git a/src/Utils.h b/src/Utils.h index b1e2cb189..682def81c 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -48,7 +48,7 @@ CC_NOINLINE cc_bool Utils_ParseIP(const String* ip, cc_uint8* data); /* Converts blocks of 3 bytes into 4 ASCII characters. (pads if needed) */ /* Returns the number of ASCII characters written. */ /* NOTE: You MUST ensure that dst is appropriately sized. */ -int Convert_ToBase64(const cc_uint8* src, int len, char* dst); +int Convert_ToBase64(const void* data, int len, char* dst); /* Converts blocks of 4 ASCII characters into 3 bytes. */ /* Returns the number of bytes written. */ /* NOTE: You MUST ensure that dst is appropriately sized. */ diff --git a/src/Window.c b/src/Window.c index 31ed7efdf..d0fb6475c 100644 --- a/src/Window.c +++ b/src/Window.c @@ -3379,10 +3379,12 @@ static void* clipboard_obj; EMSCRIPTEN_KEEPALIVE void Window_GotClipboardText(char* src) { String str; char strBuffer[512]; + int len; if (!clipboard_func) return; String_InitArray(str, strBuffer); - String_AppendUtf8(&str, src, String_CalcLen(src, 2048)); + len = String_CalcLen(src, 2048); + String_AppendUtf8(&str, (const cc_uint8*)src, len); clipboard_func(&str, clipboard_obj); clipboard_func = NULL; @@ -3489,11 +3491,12 @@ void Window_DrawFramebuffer(Rect2D r) { } void Window_FreeFramebuffer(struct Bitmap* bmp) { } EMSCRIPTEN_KEEPALIVE void Window_OnTextChanged(const char* src) { - char buffer[800]; - String str; + String str; char buffer[800]; + int len; String_InitArray(str, buffer); - String_AppendUtf8(&str, src, String_CalcLen(src, 800)); + len = String_CalcLen(src, 800); + String_AppendUtf8(&str, (const cc_uint8*)src, len); Event_RaiseString(&InputEvents.TextChanged, &str); }