Re: [PHP-DEV] [RFC] [DISCUSSION] Locale-independent float to stringcast

This is only part of a thread. view whole thread
  109267
March 24, 2020 10:53 cmbecker69@gmx.de ("Christoph M. Becker")
On 24.03.2020 at 11:03, Lynn wrote:

>> Outputting floats as strings in locales which change the decimal >> separator will have a slightly different output. In our opinion, the >> backward compatibility break won't be serious in practice > > In my opinion, this will be huge. I can't trace back where the thousands of > possible conversions are used in legacy software. There's a variety of > custom format functions, sprintf implementations, string casts, and > number_format usages. Would it be possible to trigger a warning or > deprecation when using a locale that would have a different result from > what the new result will be? If I'd use a locale that results in `3.5`, I > don't need a warning. If I use a locale that results in `3,5`, I would like > to see a warning of sorts so I can fix this before untested legacy code > will seriously break data exports.
It would certainly be *possible* to raise a warning/notice if a (non SCCP optimized) float to string conversion would have different results. This would have a (small) performance impact though, so I'd would rather avoid enforcing it (i.e. maybe temporarily introduce an INI directive for this purpose). -- Christoph M. Becker