locale for lexical_cast?

Hello! Is it possible to set a locale for the lexical_cast? It looks like that it is only possible to convert english/us numbers to a string? Example: float a = boost::lexical_cast<float>("12,3"); This would be in english 12.3. But I get a bad_cast exception for german numbers. A locale would be very helpful. Best regards Amin Kharchi

Amin Kharchi
Hello!
Is it possible to set a locale for the lexical_cast? It looks like that it is only possible to convert english/us numbers to a string?
No, it has been suggested several times and has always been rejected. (The main reason seem to be that anything ending with _cast should only take a single argument) However, as long as you are dealing with user input/output is not a big deal since locale_cast always use the current locale which I assume you set at program startup. Problems start when you need to convert things with another locale as well (e.g. SQL statements or csv files). There is a string_convert library in the vault which allows you to specify locale and formatting etc but it is very poorly documented and might not work with all compilers.
participants (2)
-
Amin Kharchi
-
Martin Adrian