From 2ef9f51df48b14556e236d14213233e1bd7f829a Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 30 Jan 2021 19:20:15 +0100 Subject: Added Support for Debian and Ubuntu, add is_valid_utf() --- include/unicode.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/unicode.h b/include/unicode.h index 9e0132b..f31cbac 100644 --- a/include/unicode.h +++ b/include/unicode.h @@ -339,5 +339,16 @@ namespace unicode { return result; } + template + bool is_valid_utf(const std::basic_string& s) + { + try { + std::for_each(utf_begin(s), utf_end(s), [](const T& c){}); + } catch(...) { + return false; + } + return true; + } + } // namespace unicode -- cgit v1.2.3