Replacement for snprintf

berni44 dlang at d-ecke.de
Wed Nov 6 13:25:38 UTC 2019


On Thursday, 31 October 2019 at 10:14:59 UTC, Guillaume Piolat 
wrote:
> Moreover, actual printf implementations seems to depend upon 
> the locale. This creates bugs (say "1,4" instead of "1.4") so 
> this behaviour depends if you want to be bug-compatible. We've 
> been hit by that in `printed` when used with a Russian locale.

Meanwhile, my implementation for the f (and F) qualifier is 
(almost) finished. Yet, the locale-stuff is missing and I do not 
manage to implement it. Maybe someone can help me:

a) I need to create some test. As far as I know, I've to execute 
"export LANG=de_DE.UTF-8" (in bash, debian) to make it use the 
german locale, which should replace the dot by a comma. 
Unfortunately writefln!"%.10f"(0.1) still writes a dot instead of 
the expected ",". Instead of "LANG" I tried several other stuff, 
like LC_ALL or LC_NUMERIC. Any idea what I do wrong here?

b) How to query the current locale from D? Actually I only need 
the number-separator in the current locale as a dchar. I found 
core.stdc.locale but do not know how to use it.




More information about the Digitalmars-d mailing list