summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
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