diff --git a/source/lib/sysdep/os/unix/udbg.cpp b/source/lib/sysdep/os/unix/udbg.cpp index 9e7d33256b..415c28d803 100644 --- a/source/lib/sysdep/os/unix/udbg.cpp +++ b/source/lib/sysdep/os/unix/udbg.cpp @@ -105,7 +105,12 @@ void debug_puts(const wchar_t* text) void debug_puts(const wchar_t* text) { - printf("%ls", text); // must not use printf, since stdout is byte-oriented + // printf doesn't like %ls strings that contain non-ASCII characters + // (it tends to print nothing and return an error), so convert to + // UTF-8 before outputting + Status err; + std::string str = utf8_from_wstring(text, &err); + printf("%s", str.c_str()); fflush(stdout); } diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index 983b8b9284..bde484dd3b 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -316,10 +316,10 @@ JSBool print(JSContext* cx, uintN argc, jsval* vp) { for (uintN i = 0; i < argc; ++i) { - std::string str; + std::wstring str; if (!ScriptInterface::FromJSVal(cx, JS_ARGV(cx, vp)[i], str)) return JS_FALSE; - debug_printf(L"%hs", str.c_str()); + debug_printf(L"%ls", str.c_str()); } fflush(stdout); JS_SET_RVAL(cx, vp, JSVAL_VOID);