From 0888d41ef756c21ec7e50ca1bfebc1b6742846e8 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 22 Feb 2004 02:49:13 +0000 Subject: [PATCH] Clamp name length by converting to wstring first, so utf-8 sequence lengths don't matter. (Combining characters would still be incorrect, but we don't support those yet anyway.) --- stepmania/src/Profile.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index c4c40c1f6d..94a3afe05f 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -520,10 +520,11 @@ void Profile::LoadEditableDataFromDir( CString sDir ) ini.GetValue("Editable","WeightPounds", m_fWeightPounds); // This is data that the user can change, so we have to validate it. - if( m_sDisplayName.GetLength() > 12 ) - m_sDisplayName = m_sDisplayName.Left(12); + wstring wstr = CStringToWstring(m_sDisplayName); + if( wstr.size() > 12 ) + wstr = wstr.substr(0, 12); + m_sDisplayName = WStringToCString(wstr); // TODO: strip invalid chars? - // TODO: is 12 chars reasonable for all UTF8 strings? CLAMP( m_fWeightPounds, 0, 500 ); }