I am using C++ Builder 10.2 Tokyo, and I have to find the position of the last space in a String
variable which has a value like "XXX YYYYY TYUR KXYZ"
;
If I use the function LastDelimiter(const System::UnicodeString Delimiters, const System::UnicodeString S)
it returns 0, but if I use the UnicodeString method::LastDelimiter( UnicodeString Delimiter )
method it returns the length of the variable.
Here is the code I am using:
void TMyClass::SetVerbo()
{
int nPosCut = 0;
if( !this->Message.IsEmpty() ) // Message is a UnicodeString (String)
{
nPosCut = this->Message.LastDelimiter(String(" ")) + 1 ;
}
if( nPosCut > 0 )
this->Verbo = this->Message.SubString(nPosCut, this->Message.Length() -nPosCut ) ;
}
While debugging the method call it gives me the correct value (34) although the result at nPosCut
is 42 (Message length), as written in the code, or 0 if I change String(" ")
to L" "
.
What am I doing wrong?