diff options
author | Michael Lutz <michi@icosahedron.de> | 2020-05-17 23:31:51 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2020-05-21 20:02:34 +0200 |
commit | c082f570cebd237c35de9caa08fcc84a9c44e95d (patch) | |
tree | 7e0e85e1a3f14db83a82e4861899578c2383529d /src/string_func.h | |
parent | 808c8198d5ab61c457d0351ff7971b75ee17c10a (diff) | |
download | openttd-c082f570cebd237c35de9caa08fcc84a9c44e95d.tar.xz |
Codechange: Use std::string when translating TTDP NewGRF string codes.
Diffstat (limited to 'src/string_func.h')
-rw-r--r-- | src/string_func.h | 10 |
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. |