logoalt Hacker News

Panzerschrek • today at 5:36 AM • 1 reply • view on HN

C number parsing functions are fundamentally broken, since they are locale-dependend. There are many bugs when one parses a number assuming it has decimal point, but later on systems with locale different from one used on developer's machine it may be suddenly comma instead of point. So, one should avoid using them almost always and use std::from_chars (available in new C++ versions) or some other thirdparty library.


Replies

spacechild1 • today at 5:58 AM

+1 for `std::from_chars`. It's also by far the fastest of all standard conversion routines.