From ef840f9e06f7f973f3d2c99316c979815609e000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=B7=E6=B8=A1?= Date: Mon, 31 Dec 2018 03:58:23 +0800 Subject: [PATCH] print string with NULL '\0' (#1428) --- libdeno/binding.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libdeno/binding.cc b/libdeno/binding.cc index bb931ca1df..eb83d2363d 100644 --- a/libdeno/binding.cc +++ b/libdeno/binding.cc @@ -205,9 +205,10 @@ void Print(const v8::FunctionCallbackInfo& args) { v8::String::Utf8Value str(isolate, args[0]); bool is_err = args.Length() >= 2 ? args[1]->BooleanValue(context).ToChecked() : false; - const char* cstr = ToCString(str); - auto& stream = is_err ? std::cerr : std::cout; - stream << cstr << std::endl; + FILE* file = is_err ? stderr : stdout; + fwrite(*str, sizeof(**str), str.length(), file); + fprintf(file, "\n"); + fflush(file); } v8::Local ImportBuf(DenoIsolate* d, deno_buf buf) {