1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-04 17:43:45 +00:00

Added UTF8 helper method that puts the string on the stack

This commit is contained in:
Bryan Roe
2019-08-26 14:15:43 -07:00
parent fcea5a600a
commit ede1ed71d5
2 changed files with 11 additions and 0 deletions

View File

@@ -960,6 +960,16 @@ char *ILibDuktape_String_WideToUTF8(duk_context *ctx, char *wstr)
return(wstr);
#endif
}
void ILibDuktape_String_UTF8ToWideEx(duk_context *ctx, char *str)
{
#ifdef WIN32
size_t tmpLen = 2 + (2 * MultiByteToWideChar(CP_UTF8, 0, (LPCCH)str, -1, NULL, 0));
LPWSTR retVal = (LPWSTR)Duktape_PushBuffer(ctx, tmpLen);
MultiByteToWideChar(CP_UTF8, 0, (LPCCH)str, -1, retVal, (int)tmpLen);
#else
duk_push_string(ctx, str);
#endif
}
char *ILibDuktape_String_UTF8ToWide(duk_context *ctx, char *str)
{
#ifdef WIN32

View File

@@ -70,6 +70,7 @@ char* ILibDuktape_String_AsWide(duk_context *ctx, duk_idx_t idx, duk_size_t *len
void ILibDuktape_String_PushWideString(duk_context *ctx, char *wstr, size_t wstrlen);
char *ILibDuktape_String_WideToUTF8(duk_context *ctx, char *wstr);
char *ILibDuktape_String_UTF8ToWide(duk_context *ctx, char *str);
void ILibDuktape_String_UTF8ToWideEx(duk_context *ctx, char *str);
#define Duktape_PushBuffer(ctx, bufSize) ILibMemory_Init(duk_push_fixed_buffer(ctx, (duk_size_t)(bufSize) + sizeof(ILibMemory_Header)), (bufSize), 0, ILibMemory_Types_OTHER)
void Duktape_Console_Log(duk_context *ctx, void *chain, ILibDuktape_LogTypes logType, char *msg, duk_size_t msgLen);