<commit_before>
#include <duct/config.hpp>
#include <duct/char.hpp>
#include <duct/string.hpp>
#include <duct/debug.hpp>
#include <duct/StringUtils.hpp>

#include <iostream>
#include <iomanip>

static duct::StringUtils::EscapeablePair const
g_esc_pair{
	"\n\r\t" ",=[]{}\"\'\\",
	"n""r""t"",=[]{}\"\'\\"
};

void
test_string(
	bool const ignore_invalids,
	duct::u8string const& str,
	duct::u8string const& expected
) {
	duct::u8string result;
	unsigned const
	escaped_count = duct::StringUtils::escape_string(
		result, str, g_esc_pair, ignore_invalids
	);
	std::cout
		<< std::setw(3) << std::left << escaped_count
		<< std::right << ": `" << result << "`'\n"
	;
	if (!expected.empty() && 0 != expected.compare(result)) {
		std::cout<commit_msg>test/text/escape: removed lonely apostrophe from output.<commit_after>
#include <duct/config.hpp>
#include <duct/char.hpp>
#include <duct/string.hpp>
#include <duct/debug.hpp>
#include <duct/StringUtils.hpp>

#include <iostream>
#include <iomanip>

static duct::StringUtils::EscapeablePair const
g_esc_pair{
	"\n\r\t" ",=[]{}\"\'\\",
	"n""r""t"",=[]{}\"\'\\"
};

void
test_string(
	bool const ignore_invalids,
	duct::u8string const& str,
	duct::u8string const& expected
) {
	duct::u8string result;
	unsigned const
	escaped_count = duct::StringUtils::escape_string(
		result, str, g_esc_pair, ignore_invalids
	);
	std::cout
		<< std::setw(3) << std::left << escaped_count
		<< std::right << ": `" << result << "`\n"
	;
	if (!expected.empty() && 0 != expected.compare(result)) {
		std::cout
{'fraction_non_alphanumeric': 0.20534550195567144, 'fraction_numerical': 0.00651890482398957, 'mean_word_length': 5.2145748987854255, 'pattern_counts': {'":': 2, '<': 45, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6774603', 'n_tokens_mistral': 607, 'n_tokens_neox': 583, 'n_words': 112}