OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/ostreams.h" | 5 #include "src/ostreams.h" |
6 | 6 |
7 #if V8_OS_WIN | 7 #if V8_OS_WIN |
8 #define snprintf sprintf_s | 8 #define snprintf sprintf_s |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 } | 59 } |
60 | 60 |
61 } // namespace | 61 } // namespace |
62 | 62 |
63 | 63 |
64 std::ostream& operator<<(std::ostream& os, const AsReversiblyEscapedUC16& c) { | 64 std::ostream& operator<<(std::ostream& os, const AsReversiblyEscapedUC16& c) { |
65 return PrintUC16(os, c.value, IsOK); | 65 return PrintUC16(os, c.value, IsOK); |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 std::ostream& operator<<(std::ostream& os, const AsEscapedUC16ForJSON& c) { | |
70 if (c.value == '\n') { | |
Sven Panne
2015/01/28 15:00:43
I think a 'comb-like' pattern plus inserting strin
danno
2015/01/28 15:30:12
Done.
| |
71 os << '\\'; | |
72 return os << 'n'; | |
73 } else if (c.value == '\r') { | |
74 os << '\\'; | |
75 return os << 'r'; | |
76 } else if (c.value == '\'') { | |
77 os << '\\'; | |
78 return os << '\''; | |
79 } else if (c.value == '\"') { | |
80 os << '\\'; | |
81 return os << '\"'; | |
82 } | |
83 return PrintUC16(os, c.value, IsOK); | |
84 } | |
85 | |
86 | |
69 std::ostream& operator<<(std::ostream& os, const AsUC16& c) { | 87 std::ostream& operator<<(std::ostream& os, const AsUC16& c) { |
70 return PrintUC16(os, c.value, IsPrint); | 88 return PrintUC16(os, c.value, IsPrint); |
71 } | 89 } |
72 | 90 |
73 } // namespace internal | 91 } // namespace internal |
74 } // namespace v8 | 92 } // namespace v8 |
OLD | NEW |