d-money ctor(string) has bug, be careful! EUR("1.23456") ==> ctor ==> 3.3456EUR

Basile B. b2.temp at gmx.com
Sun May 24 18:54:55 UTC 2020


On Sunday, 24 May 2020 at 18:30:38 UTC, mw wrote:
> On Sunday, 24 May 2020 at 18:15:09 UTC, Basile B. wrote:
>> On Sunday, 24 May 2020 at 17:06:43 UTC, mw wrote:
>>> On Friday, 22 May 2020 at 05:26:45 UTC, mw wrote:
>>>>[...]
>>>
>>> For anyone who's using this package, just submitted the PR to 
>>> fix it:
>>>
>>> https://github.com/qznc/d-money/pull/12
>>
>> there's also parsing that is not super compliant
>>
>> EUR y = EUR("1.000.000,00");
>> writeln(y);                     // F!
>
> Added comment here on git:
>
> https://github.com/qznc/d-money/pull/12#issuecomment-633272988
>
> =====================================
> The parsing regex used internally is a very simple one:
> https://github.com/qznc/d-money/blob/master/source/money.d#L98
>
> I don't want to enhanced it to be a full sscanf().
>
> This is just a maintenance bug fix.

No this is an issue on itw own. The thousands and the decimal 
separator should be template parameters or customizable in some 
way.


More information about the Digitalmars-d mailing list