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.)
This commit is contained in:
Glenn Maynard
2004-02-22 02:49:13 +00:00
parent de3a1c8156
commit 0888d41ef7
+4 -3
View File
@@ -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 );
}