From 037aa2192fa9b3de481e2acf125180bab16d6084 Mon Sep 17 00:00:00 2001 From: Techjar Date: Wed, 21 Nov 2018 00:15:44 -0500 Subject: NetPlay: Limit nickname length Ridiculously long nicknames cause UI silliness, so 30 characters seems like a reasonable limit, as it's the same as the forum. --- Source/Core/Common/StringUtil.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Source/Core/Common/StringUtil.cpp') diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index c44f3fa7b1..14b7ac832b 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -412,6 +412,12 @@ void StringPopBackIf(std::string* s, char c) s->pop_back(); } +size_t StringUTF8CodePointCount(const std::string& str) +{ + return str.size() - + std::count_if(str.begin(), str.end(), [](char c) -> bool { return (c & 0xC0) == 0x80; }); +} + #ifdef _WIN32 std::wstring CPToUTF16(u32 code_page, std::string_view input) -- cgit v1.2.3