Commit c3c702a8 authored by Andrew Price's avatar Andrew Price
Browse files

duktape: Convert cesu8 to utf8 in js_mwexec and js_say

parent 95c3f705
Loading
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ static duk_ret_t js_print(duk_context *cx)

static duk_ret_t js_mwexec(duk_context *cx)
{
	char *mutablestr;
	char *utf8;

	if (duk_is_undefined(cx, -1)) {
		fprintf(stderr, "mwjs error: exec() requires an argument\n");
@@ -164,15 +164,17 @@ static duk_ret_t js_mwexec(duk_context *cx)
		fprintf(stderr, "mwjs error: exec() requires a string\n");
		return DUK_RET_SYNTAX_ERROR;
	}
	mutablestr = strdup(duk_get_string(cx, -1));
	utf8 = cesu8_to_utf8(duk_get_string(cx, -1));
	duk_pop(cx);
	DoCommand(mutablestr, chattable);
	free(mutablestr);
	DoCommand(utf8, chattable);
	free(utf8);
	return 0;
}

static duk_ret_t js_say(duk_context *cx)
{
	char *utf8;

	if (duk_is_undefined(cx, -1)) {
		fprintf(stderr, "mwjs error: say() requires an argument\n");
		return DUK_RET_SYNTAX_ERROR;
@@ -186,8 +188,10 @@ static duk_ret_t js_say(duk_context *cx)
		fprintf(stderr, "mwjs error: say() takes a string or a number\n");
		return DUK_RET_ERROR;
	}
	chat_say(duk_to_string(cx, -1));
	utf8 = cesu8_to_utf8(duk_to_string(cx, -1));
	chat_say(utf8);
	duk_pop(cx);
	free(utf8);
	return 0;
}