Changeset - r25560:275e9355119a
[Not reviewed]
master
0 2 0
rubidium42 - 3 years ago 2021-05-29 14:02:53
rubidium@openttd.org
Codechange: add std::string variant of Utf8StringLength
2 files changed with 11 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/string.cpp
Show inline comments
 
@@ -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.
src/string_func.h
Show inline comments
 
@@ -166,6 +166,7 @@ static inline const char *Utf8PrevChar(c
 
}
 

	
 
size_t Utf8StringLength(const char *s);
 
size_t Utf8StringLength(const std::string &str);
 

	
 
/**
 
 * Is the given character a lead surrogate code point?
0 comments (0 inline, 0 general)