Re: Capitalizing the first letter in a CString
Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance
I think there's a _ttoupper or something similar in tchar.h that makes it Unicode-aware.
Your solution looks about as good as it gets. I was going to propose a slightly different
solution, but I don't think it is going to be any faster.
joe
On Wed, 1 Feb 2006 19:33:27 -0800, "Okie" <Okie@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>How about
>
>string.SetAt(0, toupper(string[0]));
>
>There's also towupper() for wide characters. Never used it.
>
>Okie
>
>
>"Steve Russell" wrote:
>
>> Is there a more efficient way to capitalize the first letter in a string
>> than what I'm doing below?
>>
>> CString firstletter = string.Left(1);
>> firstletter.MakeUpper();
>> string = firstletter + string.Mid(1);
>>
>>
>>
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.