4 ms·
std::from_chars / std::to_chars are explicitly made to only operate in the C locale, so basically ASCII texts. It's not meant for parsing user-input strings but
by jcelerier 2y ago
std::from_chars / std::to_chars are explicitly made to only operate in the C locale, so basically ASCII texts. It's not meant for parsing user-input strings but rather text protocols with maximal efficiency (and locale support prevents that).
E.g. "۱۲۳٤" isn't as far as I know a valid number to put in a json file, http content-length or CSS property. Maybe it'd be ok in a CSV but realistically have you ever seen a big data csv encoded in non-ascii numbers?
- gpderetta 2y agoThis way your spreadsheet could interpret the data it loads from a CVS differently depending on on the locale of the machine it is running on. Of course nobody would design an application like that.
- einpoklum 2y ago> have you ever seen a big data csv encoded in non-ascii numbers? Let me ask you this: How much data have you processed which comes from human user input in Arabic-speaking countries?
- jcelerier 2y agoIf your CSV is defined to contain straight, unparsed user input it's wrong no matter the context. If it's defined to contain numbers then if at some point between [user input] and [csv output] you don't have a pass where the value is parsed, validated and converted to one of your programming language's actual number data types before being passed to your CSV writer, then your code is wrong.