views:

186

answers:

2

Hi all,

is there a counterpart of the Delete procedure that could be used for widestrings? Or should I just use copy and concatenate the resulting WideStrings?

+4  A: 

Internal RTL functions like Delete, Insert, Length, etc works both for Ansi and Wide strings.

For example, Delete call on WideString is transformed into WStrDelete call (see System.pas).

Alexander
are you sure about that? in delphi 2006 it is just an assembler function...
Bartosz Radaczyński
Yes, I'm pretty sure about it - just checked it right now in D2006. Delete for String (AnsiString) is converted into LStrDelete call and Delete for WideString is converted into WStrDelete call (see CPU view).
Alexander
yeah, OK, I noticed that in the meantime as well, but thanks anyway.
Bartosz Radaczyński
+4  A: 

Delete is a "compiler magic" function. The compiler uses its knowledge of the basic data type to handle the operation appropriately. For most arrays, it can simply translate the information you write in your code into the actual offset and number of bytes that need to be deleted, and passes that to the _Delete assembly routine instead. For WideStrings, as Alexander pointed out, it's got a special _WStrDelete routine.

Bottom line: If you can pass an array or string to Delete and it compiles, it should run just fine.

Mason Wheeler
haha, I just love that answer - especially that Delphi does implicit conversion from String to WideString, whenever there is no overloaded version of the function...
Bartosz Radaczyński