Just looked at diff code. Question
Should that be AValue not Value
Well spotted.
I sent in a fix for the fix to the bugtracker, hope it gets applied soon.
Also would the result be set? Maybe
If AValue=EmptyStr then Exit(EmptyStr);
I didn't think so.
MaskUtils is a bit odd. Delphi uses it to do stuff with TMaskEdit.
When I came to Lazarus, TMaskEdit was utterly broken.
The stuff in MaskUtils could not be applied to TMaskEdit.
Hence over time I fixed TMaskEdit on Lazarus side.
The release cycle of fpc is too slow to wait for that (and at the time I did not feel comfortable to suggest any patches to the fpc team).
At that time TMaskEdit did not support UTF-8, it only worked with (lower) ASCII characters.
Since some years now, it does work with UTF-8 (well, it might choke on surrogate pairs).
So, after a while fpc's MaskUtils implementation behaved rather different than similar functions in TMaskEdit (the latter being heavily "black-box" tested against Delphi's behaviour).
Once noticed, I rewrote large parts of the MaskUtils unit, so that it would act like TMaskEdit would.
And since FormatMaskText (in Lazarus) calls a TMaskEdit function to accomplish this, and in Lazarus this function must
not return an empty sting in this case, it was implemented in MaskUtils in the same way.
"Backporting" this to fpc meant that I had to change all the UTF-8 related code back to directly accessing strings by index. (You cannot use MaskUtils with UTF-8 encoded strings.)
And that's where the bug was introduced.
In the mean time I have safeguarded this particular bug in Lazarus as well, since it should not depend on an implementation detail of a helper function.
Bart