Is there a caseinsensitive version of strrchr and wcsrchr?(c++)

95 Views Asked by At

I try to check if variable ends with expression.

My current code is this:

(strchr(variable.data(), tolower(expression[0])) || strchr(variable.data(), toupper(expression[0]))) && _stricmp((strrchr(variable.data(), tolower(expression[0]))? strrchr(variable.data(), tolower(expression[0])) : strrchr(variable.data(), toupper(expression[0]))), expression.data()) == 0

It works. But with a case-insensitive version of strrchr and strchr I can simlpify it. I also need the case-insensitive versions of wcsrchr and wcsrchr for UTF16-strings:

(wcschr(variable.data(), tolower(expression[0])) || wcschr(variable.data(), toupper(expression[0]))) && _wcsicmp((wcsrchr(variable.data(), tolower(expression[0])) ? wcsrchr(variable.data(), tolower(expression[0])) : wcsrchr(variable.data(), toupper(expression[0]))), expression.data()) == 0

I´m open for other simplifications.

I can´t write additional methods because the mainprogram is a vs-extension written in c#.

0

There are 0 best solutions below