You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/04/16 20:20:13 UTC
[couchdb] 02/07: Encode JavaScript strings as UTF-8 for printing
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a commit to branch fix-couchjs-utf8-conversions-take2
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 170b6bb630e326272a5c73a43fcecc8d3d52d2c7
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Tue Apr 14 13:23:48 2020 -0500
Encode JavaScript strings as UTF-8 for printing
---
src/couch/priv/couch_js/60/util.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/couch/priv/couch_js/60/util.cpp b/src/couch/priv/couch_js/60/util.cpp
index 3945114..2cf02fd 100644
--- a/src/couch/priv/couch_js/60/util.cpp
+++ b/src/couch/priv/couch_js/60/util.cpp
@@ -266,9 +266,8 @@ couch_print(JSContext* cx, unsigned int argc, JS::CallArgs argv)
if (argc > 1 && argv[1].isTrue()) {
stream = stderr;
}
- JSString* str = JS::ToString(cx, argv.get(0));
- bytes = reinterpret_cast<uint8_t*>(JS_EncodeString(cx, str));
- fprintf(stream, "%s", bytes);
+ std::string val = js_to_string(cx, argv.get(0));
+ fprintf(stream, "%s", val.c_str());
JS_free(cx, bytes);
}