Codechange: Use std::string when translating TTDP NewGRF string codes.

This commit is contained in:
Michael Lutz
2020-05-17 23:31:51 +02:00
parent 808c8198d5
commit c082f570ce
5 changed files with 188 additions and 182 deletions

View File

@@ -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.