Index: src/ostreams.cc |
diff --git a/src/ostreams.cc b/src/ostreams.cc |
index a7a67f5d2f06002fc9899b7c391476fd16022932..120db257cd19e27fe91068c4dab99dfba709e9f7 100644 |
--- a/src/ostreams.cc |
+++ b/src/ostreams.cc |
@@ -3,6 +3,7 @@ |
// found in the LICENSE file. |
#include "src/ostreams.h" |
+#include "src/objects.h" |
#if V8_OS_WIN |
#if _MSC_VER < 1900 |
@@ -60,6 +61,16 @@ std::ostream& PrintUC16(std::ostream& os, uint16_t c, bool (*pred)(uint16_t)) { |
return os << buf; |
} |
+ |
+std::ostream& PrintUC32(std::ostream& os, int32_t c, bool (*pred)(uint16_t)) { |
+ if (c <= String::kMaxUtf16CodeUnit) { |
+ return PrintUC16(os, static_cast<uint16_t>(c), pred); |
+ } |
+ char buf[13]; |
+ snprintf(buf, sizeof(buf), "\\u{%06x}", c); |
+ return os << buf; |
+} |
+ |
} // namespace |
@@ -81,5 +92,10 @@ std::ostream& operator<<(std::ostream& os, const AsUC16& c) { |
return PrintUC16(os, c.value, IsPrint); |
} |
+ |
+std::ostream& operator<<(std::ostream& os, const AsUC32& c) { |
+ return PrintUC32(os, c.value, IsPrint); |
+} |
+ |
} // namespace internal |
} // namespace v8 |