Chromium Code Reviews| Index: src/ostreams.cc |
| diff --git a/src/ostreams.cc b/src/ostreams.cc |
| index a7a67f5d2f06002fc9899b7c391476fd16022932..1652d4f6d57086884767a98101f7cbfdb7b5305d 100644 |
| --- a/src/ostreams.cc |
| +++ b/src/ostreams.cc |
| @@ -60,6 +60,14 @@ 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 <= 0xffff) return PrintUC16(os, static_cast<uint16_t>(c), pred); |
|
erikcorry
2016/01/20 10:47:05
kMaxUtf16CodeUnit
Yang
2016/01/20 13:06:20
Done.
|
| + char buf[12]; |
|
erikcorry
2016/01/20 10:47:05
Perhaps 13 so that if c.value is somehow a maximal
Yang
2016/01/20 13:06:20
Done.
|
| + snprintf(buf, sizeof(buf), "\\u{%06x}", c); |
| + return os << buf; |
| +} |
| + |
| } // namespace |
| @@ -81,5 +89,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 |