Bug in MemoryBlock.StringValue

Feedback Case Number: 69762

mbString.StringValue( 0, mbString.Size, Encodings.UTF8 )

When size is zero an Out Of Bounds exception is raised. Surely this should just return an empty string.



Hm…I would argue that it’s correct behavior.

String.Left( 0 ), String.Right( 0 ) and String.Middle( 0, 0 ) don’t generate exceptions, so it should be consistent, at least.


True. Then it’s a bug. :slight_smile:

1 Like

I can well imagine that this is intentional behavior. Therefore I check all parameters before calling a function (same as like a nil check for record/row sets or object access in general). If you want a StringValue of zero length from a memory block, there is maybe something wrong before the function call😉

One significant use of MemoryBlock is for very fast string concatenation. Simply having an empty string isn’t an error.