File tree 4 files changed +61
-10
lines changed
4 files changed +61
-10
lines changed Original file line number Diff line number Diff line change @@ -44,4 +44,5 @@ add_library(cs STATIC
44
44
writer-cov.cc
45
45
writer-html.cc
46
46
writer-json.cc
47
+ writer-json-common.cc
47
48
)
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (C) 2011 - 2023 Red Hat, Inc.
3
+ *
4
+ * This file is part of csdiff.
5
+ *
6
+ * csdiff is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * any later version.
10
+ *
11
+ * csdiff is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with csdiff. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ #include " writer-json-common.hh"
21
+
22
+ #include < boost/nowide/utf/convert.hpp>
23
+
24
+ std::string sanitizeUTF8 (const std::string &str)
25
+ {
26
+ using boost::nowide::utf::convert_string;
27
+
28
+ // every non-UTF8 sequence will be replaced with 0xEF 0xBF 0xBD which
29
+ // corresponds to REPLACEMENT CHARACTER U+FFFD
30
+ return convert_string<char >(str.data (), str.data () + str.size ());
31
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (C) 2011 - 2023 Red Hat, Inc.
3
+ *
4
+ * This file is part of csdiff.
5
+ *
6
+ * csdiff is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * any later version.
10
+ *
11
+ * csdiff is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with csdiff. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ #ifndef H_GUARD_WRITER_JSON_COMMON_H
21
+ #define H_GUARD_WRITER_JSON_COMMON_H
22
+
23
+ #include < string>
24
+
25
+ // / sanitize byte sequences that are not valid in UTF-8 encoding
26
+ std::string sanitizeUTF8 (const std::string &str);
27
+
28
+ #endif /* H_GUARD_WRITER_JSON_COMMON_H */
Original file line number Diff line number Diff line change 22
22
#include " abstract-tree.hh"
23
23
#include " regex.hh"
24
24
#include " version.hh"
25
+ #include " writer-json-common.hh"
25
26
26
27
#include < algorithm>
27
28
#include < queue>
28
29
29
30
#include < boost/json/src.hpp>
30
31
#include < boost/lexical_cast.hpp>
31
- #include < boost/nowide/utf/convert.hpp>
32
32
33
33
using namespace boost ::json;
34
34
35
- static inline std::string sanitizeUTF8 (const std::string &str)
36
- {
37
- using boost::nowide::utf::convert_string;
38
-
39
- // every non-UTF8 sequence will be replaced with 0xEF 0xBF 0xBD which
40
- // corresponds to REPLACEMENT CHARACTER U+FFFD
41
- return convert_string<char >(str.data (), str.data () + str.size ());
42
- }
43
-
44
35
static void prettyPrint (std::ostream&, const value&, std::string* = nullptr );
45
36
46
37
static inline void prettyPrintArray (
You can’t perform that action at this time.
0 commit comments