diff --git a/src/common/Variant.hxx b/src/common/Variant.hxx index 3e213047c..06870bd73 100644 --- a/src/common/Variant.hxx +++ b/src/common/Variant.hxx @@ -57,8 +57,20 @@ class Variant // Conversion methods const string& toString() const { return data; } const char* const toCString() const { return data.c_str(); } - const Int32 toInt() const { return atoi(data.c_str()); } - const float toFloat() const { return float(atof(data.c_str())); } + const Int32 toInt() const { + istringstream ss(data); + Int32 parsed; + ss >> parsed; + + return parsed; + } + const float toFloat() const { + istringstream ss(data); + float parsed; + ss >> parsed; + + return parsed; + } const bool toBool() const { return data == "1" || data == "true"; } const GUI::Size toSize() const { return GUI::Size(data); }