Noel and Floyd: There is a serious difference between using slicing and and manual string concatenation.
But if you insist on instring manipulation:
where you do all your "in string" modification in that single function which accepts a byte ptr
And just to make that clear: I actually thought about a solution.
But the target and "things we want to avoid" was not clearly specified -> any answer is correct that achieves the result in an efficient and intelligent way.
Or do what has been suggested like 8-12 months ago: Do what java does and implement a stringbuffer class that holds a Bytestream you can alter at any place.
That wouldn't even be hard (byte ptr to a byte array or using a real TStream to allow encrypted streams and the like)
But if you insist on instring manipulation:
temp:byte ptr = Somefunction(str.toCstring()) str = String.FromCString( temp ) free( temp )
where you do all your "in string" modification in that single function which accepts a byte ptr
And just to make that clear: I actually thought about a solution.
But the target and "things we want to avoid" was not clearly specified -> any answer is correct that achieves the result in an efficient and intelligent way.
Or do what has been suggested like 8-12 months ago: Do what java does and implement a stringbuffer class that holds a Bytestream you can alter at any place.
That wouldn't even be hard (byte ptr to a byte array or using a real TStream to allow encrypted streams and the like)