From 4de8f0118e1baf31cf4c859881dfbf39014b566f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 11 May 2014 23:59:19 +0100 Subject: Use raw_convert instead of boost::lexical_cast as it seems that lexical_cast will sometimes use a thousands separator (i.e. it will convert 1234 to a string 1,234). It appears not to be possible safely to turn this off (you have to set the global locale). Instead, raw_convert uses a stringstream which you can imbue() with std::locale::classic() to turn off the locale-specific behaviour. --- src/types.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/types.cc') diff --git a/src/types.cc b/src/types.cc index 693b9ab2..f45e3345 100644 --- a/src/types.cc +++ b/src/types.cc @@ -1,3 +1,22 @@ +/* + Copyright (C) 2012-2014 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + #include #include #include @@ -5,6 +24,7 @@ #include #include "types.h" #include "exceptions.h" +#include "raw_convert.h" using namespace std; using namespace libdcp; @@ -17,8 +37,8 @@ Fraction::Fraction (string s) if (b.size() != 2) { boost::throw_exception (XMLError ("malformed fraction " + s + " in XML node")); } - numerator = lexical_cast (b[0]); - denominator = lexical_cast (b[1]); + numerator = raw_convert (b[0]); + denominator = raw_convert (b[1]); } bool -- cgit v1.2.3