Failed to search a character using CString::Find

Avinash Bansod 21 Reputation points
2022-12-06T10:43:41.333+00:00

Hi,

I want to find if the character ':' is present in a Chinese string "1.00 单位:14.30 单位".

But it is returning me -1 all the time though the character ':' is present in the above string.

CString myString = _T( "1.00 单位:14.30 单位");
int index = myString.Find(':');

Here I am expecting the 'index' value to be 7 but getting as -1.

Thanks in advance for any suggestion or help.

Developer technologies C++
{count} votes

Accepted answer
  1. David Lowndes 4,726 Reputation points
    2022-12-06T11:34:53.857+00:00

    Your character isn't a ':', it's ':'

    Try:
    int index = myString.Find( _T(':') );


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.