From 0d1dcc9f4cadce282a6181d8f40f21809edb4ba8 Mon Sep 17 00:00:00 2001 From: atraczyk <andreastraczyk@gmail.com> Date: Fri, 20 Oct 2017 11:23:12 -0400 Subject: [PATCH] fallback avatar: fix getUpperInitial to skip spaces if any Change-Id: I8446fc7a88c8c1b2a5a76cf6ad60f8fc8e784a4f --- Utils.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Utils.h b/Utils.h index d48ed2c..bfbf10f 100644 --- a/Utils.h +++ b/Utils.h @@ -336,14 +336,17 @@ TrimCmd(Platform::String^ s) String^ getUpperInitial(String^ str) { - if (str != nullptr || str != "") { - std::wstring s(str->Data()); - auto it = str->Begin(); - wchar_t ch[] = L" "; - ch[0] = towupper(it[0]); - return ref new String(ch); + if (str == nullptr || str == "") { + return "?"; } - return "?"; + auto it = str->Begin(); + wchar_t ch[] = L" "; + int index = 0; + ch[0] = towupper(*it++); + while (it != str->End() && ch[0] == ' ') { + ch[0] = towupper(*it++); + } + return ref new String(ch); } Platform::String^ -- GitLab