File tree Expand file tree Collapse file tree 4 files changed +61
-10
lines changed
Expand file tree Collapse file tree 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
4444 writer-cov.cc
4545 writer-html.cc
4646 writer-json.cc
47+ writer-json-common.cc
4748)
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 2222#include " abstract-tree.hh"
2323#include " regex.hh"
2424#include " version.hh"
25+ #include " writer-json-common.hh"
2526
2627#include < algorithm>
2728#include < queue>
2829
2930#include < boost/json/src.hpp>
3031#include < boost/lexical_cast.hpp>
31- #include < boost/nowide/utf/convert.hpp>
3232
3333using namespace boost ::json;
3434
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-
4435static void prettyPrint (std::ostream&, const value&, std::string* = nullptr );
4536
4637static inline void prettyPrintArray (
You can’t perform that action at this time.
0 commit comments