mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
Codechange: add std::string variant of Utf8StringLength
This commit is contained in:
parent
0125ba82e8
commit
b4aedef848
@ -395,6 +395,16 @@ size_t Utf8StringLength(const char *s)
|
|||||||
return len;
|
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.
|
* Convert a given ASCII string to lowercase.
|
||||||
|
@ -166,6 +166,7 @@ static inline const char *Utf8PrevChar(const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t Utf8StringLength(const char *s);
|
size_t Utf8StringLength(const char *s);
|
||||||
|
size_t Utf8StringLength(const std::string &str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the given character a lead surrogate code point?
|
* Is the given character a lead surrogate code point?
|
||||||
|
Loading…
Reference in New Issue
Block a user