<commit_before>#include "../../src/svgdom/dom.hpp"

#include <clocale>

#include <utki/debug.hpp>

#include <papki/fs_file.hpp>

int main(int argc, char** argv){
	std::string filename;
	switch(argc){
		case 0:
		case 1:
			std::cout << "Warning: expected 1 argument: <svg-file>" << std::endl;
			std::cout << "\tGot 0 arguments, assuming <svg-file>=tiger.svg" << std::endl;
			filename = "tiger.svg";
			break;
		default:
		case 2:
			filename = argv[1];
			break;
	}

	// make sure the locale does not affect parsing (decimal delimiter can be "." or "," in different locales)
	// so, set DE locale which has "," to make sure it does not affect the parsing
	std::setlocale(LC_ALL, "de_DE.UTF-8");
	
	auto dom = svgdom::load(papki::fs_file(filename));
	
//	TRACE_ALWAYS(<< "file read" << std::endl)
	
	ASSERT_ALWAYS(dom)
	
	auto str = dom->to_string();
//	TRACE_ALWAYS(<< str << std::endl)
	
	papki::fs_file out_file("out.svg");
	papki::file::guard file_guard(out_file, papki::file::mode::create);
	out_file.write(utki::make_span(str));<commit_msg>set test locale but and print warning in case of error<commit_after>#include "../../src/svgdom/dom.hpp"

#include <clocale>

#include <utki/debug.hpp>

#include <papki/fs_file.hpp>

int main(int argc, char** argv){
	std::string filename;
	switch(argc){
		case 0:
		case 1:
			std::cout << "Warning: expected 1 argument: <svg-file>" << std::endl;
			std::cout << "\tGot 0 arguments, assuming <svg-file>=tiger.svg" << std::endl;
			filename = "tiger.svg";
			break;
		default:
		case 2:
			filename = argv[1];
			break;
	}

	// make sure the locale does not affect parsing (decimal delimiter can be "." or "," in different locales)
	// so, set DE locale which has "," to make sure it does not affect the parsing
	if(!std::setlocale(LC_ALL, "de_DE.UTF-8")){
		utki::log([](auto& o){o << "WARNING: failed to set locale de_DE.UTF-8, perhaps the locale is not installed. Testing that locale does not affect parsing will not be done.";});
	}
	
	auto dom = svgdom::load(papki::fs_file(filename));
	
//	TRACE_ALWAYS(<< "file read" << std::endl)
	
	ASSERT_ALWAYS(dom)
	
	auto str = dom->to_string();
//	TRACE_ALWAYS(<< str << std::endl)
	
	papki::fs_file out_file("out.svg");
	papki::file::guard file_guard(out_file, papki::file::mode::create);
	out_file.write(utki::make_span(str));
{'fraction_non_alphanumeric': 0.17198275862068965, 'fraction_numerical': 0.00646551724137931, 'mean_word_length': 4.263038548752834, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 15, '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': '1423104', 'n_tokens_mistral': 907, 'n_tokens_neox': 831, 'n_words': 226}