diff options
author | rubidium42 <rubidium@openttd.org> | 2021-05-29 16:02:53 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-05-29 19:02:18 +0200 |
commit | b4aedef848822649d3f7a045504eb2a9870b4b7e (patch) | |
tree | dcade3be2cc07f795b1b56e658437c356b814c6b /src/string.cpp | |
parent | 0125ba82e8b94461894a9628dea6552c0bbfa38d (diff) | |
download | openttd-b4aedef848822649d3f7a045504eb2a9870b4b7e.tar.xz |
Codechange: add std::string variant of Utf8StringLength
Diffstat (limited to 'src/string.cpp')
-rw-r--r-- | src/string.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/string.cpp b/src/string.cpp index 1cf61e8b4..e9a619c40 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -395,6 +395,16 @@ size_t Utf8StringLength(const char *s) return len; } +/** + * Get the length of an UTF-8 encoded string in number of characters + * and thus not the number of bytes that the encoded string contains. + * @param s The string to get the length for. + * @return The length of the string in characters. + */ +size_t Utf8StringLength(const std::string &str) +{ + return Utf8StringLength(str.c_str()); +} /** * Convert a given ASCII string to lowercase. |