I have a Unicode string that I want to limit to 30 characters. I populate the string from a query, so I don't know the length to begin with. I want to simply snip off all of the characters past 30. I found the UnicodeString::Delete()
method, but I don't know how to use it.
I tried this to no avail:
mystring = <code here to populate the unicode string mystring>
Delete(mystring, 30, 100);
You are actually trying to call
System::Delete()
, which is not available to C++, only to Delphi. Internally,UnicodeString::Delete()
callsSystem::Delete()
usingthis
as the string to manipulate.UnicodeString::Delete()
is a non-static class method. You need to call it on the string object itself, not as a separate function. Also,Delete()
is 1-indexed, not 0-indexed:If you want to use 0-indexing, use
UnicodeString::Delete0()
instead:However, the
UnicodeString::SetLength()
method would be more appropriate in this situation:Alternatively, you can use
UnicodeString::SubString()
/UnicodeString::SubString0()
: