- changed status to resolved
VarToStr issue?
Issue #232
closed
Hi.
In Delphi, the instruction:
VarToStr (null)
returns the empty string.
In DWS it returns the string "Null".
Is this a deliberate behavior or is it an anomaly?
Thanks.
Comments (4)
-
repo owner -
I can’t think of a single case where I have wanted (and expected)
VarToStr
to return anything other than an empty string onnull
. The current behavior is just an annoyance which must be worked around. -
repo owner IIRC initial motivation was when dealing with data coming from a database that distinguishes between null and empty strings (ie. any DB except Oracle), as “null” is only sporadically encountered outside that context. Unassigned maps to an empty string, and is the common value outside database uses.
I’ll add a variable to specify a custom string representation for null.
-
repo owner - changed status to closed
Fixed by 269a409
- Log in to comment
Yes, it's an explicit behavior defined in dwsUtils.VariantToString
VarToStr() in DWS minimizes reliance on the Delphi RTL's VarToStr() implementation in an attempt to preserve more information and avoid various stability and safety issues.