mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-24 04:04:31 +00:00
Updated ASCII conversion to throw exception on failure
This commit is contained in:
@@ -192,8 +192,14 @@ duk_ret_t ILibDuktape_GenericMarshal_Variable_Val_ASTRING(duk_context *ctx)
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (size == 0) { size = (int)wcsnlen_s((const wchar_t*)ptr, sizeof(astr) * 2); }
|
if (size == 0) { size = (int)wcsnlen_s((const wchar_t*)ptr, sizeof(astr) * 2); }
|
||||||
wcstombs_s(&s, astr, sizeof(astr), (const wchar_t*)ptr, size);
|
if (wcstombs_s(&s, astr, sizeof(astr), (const wchar_t*)ptr, size) == 0)
|
||||||
duk_push_string(ctx, (char*)astr);
|
{
|
||||||
|
duk_push_string(ctx, (char*)astr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return(ILibDuktape_Error(ctx, "String Conversion Error: %d", GetLastError()));
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
duk_push_lstring(ctx, (const char*)ptr, size);
|
duk_push_lstring(ctx, (const char*)ptr, size);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user