summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2021-01-30 19:20:15 +0100
committerRoland Reichwein <mail@reichwein.it>2021-01-30 19:20:15 +0100
commit2ef9f51df48b14556e236d14213233e1bd7f829a (patch)
treef5230e326501ebaec1baca9615dc69b7538f1911 /include
parentee9dfd30e8c02e9a7457385786218d2b4b935720 (diff)
Added Support for Debian and Ubuntu, add is_valid_utf()
Diffstat (limited to 'include')
-rw-r--r--include/unicode.h11
1 files changed, 11 insertions, 0 deletions
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<typename T>
+ bool is_valid_utf(const std::basic_string<T>& s)
+ {
+ try {
+ std::for_each(utf_begin<T>(s), utf_end<T>(s), [](const T& c){});
+ } catch(...) {
+ return false;
+ }
+ return true;
+ }
+
} // namespace unicode