summaryrefslogtreecommitdiff
path: root/src/string_func.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/string_func.h')
-rw-r--r--src/string_func.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/string_func.h b/src/string_func.h
index 9942e9a6a..002b8f217 100644
--- a/src/string_func.h
+++ b/src/string_func.h
@@ -25,6 +25,7 @@
#define STRING_FUNC_H
#include <stdarg.h>
+#include <iosfwd>
#include "core/bitmath_func.hpp"
#include "string_type.h"
@@ -79,6 +80,7 @@ bool IsValidChar(WChar key, CharSetFilter afilter);
size_t Utf8Decode(WChar *c, const char *s);
size_t Utf8Encode(char *buf, WChar c);
+size_t Utf8Encode(std::ostreambuf_iterator<char> &buf, WChar c);
size_t Utf8TrimString(char *s, size_t maxlen);
@@ -89,6 +91,14 @@ static inline WChar Utf8Consume(const char **s)
return c;
}
+template <class Titr>
+static inline WChar Utf8Consume(Titr &s)
+{
+ WChar c;
+ s += Utf8Decode(&c, &*s);
+ return c;
+}
+
/**
* Return the length of a UTF-8 encoded character.
* @param c Unicode character.