1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 00:03: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