diff --git a/CGALimageIO/src/CGALimageIO/inr.cpp b/CGALimageIO/src/CGALimageIO/inr.cpp index 13c49772c7a..11175d5c7bf 100644 --- a/CGALimageIO/src/CGALimageIO/inr.cpp +++ b/CGALimageIO/src/CGALimageIO/inr.cpp @@ -43,7 +43,19 @@ typedef struct { } stringListHead; /* string list descriptor */ +#include +class Set_numeric_locale { + const char * old_locale; +public: + Set_numeric_locale(const char* locale) + : old_locale(std::setlocale(LC_NUMERIC, locale)) + { + } + ~Set_numeric_locale() { + std::setlocale(LC_NUMERIC, old_locale); + } +}; static void addStringElement(stringListHead *strhead, const char *str); @@ -59,6 +71,8 @@ int _writeInrimageHeader(const _image *im, ENDIANNESS end) { unsigned int pos, i; char type[30], endianness[5], buf[257], scale[20]; + Set_numeric_locale num_locale("C"); + if(im->openMode != OM_CLOSE) { /* fix word kind */ switch(im->wordKind) { @@ -209,6 +223,8 @@ int readInrimageHeader(const char *,_image *im) { stringListHead strl = { NULL, NULL }; stringListElement *oel, *el; + Set_numeric_locale num_locale("C"); + if(im->openMode != OM_CLOSE) { /* read image magic number */ if(!fgetns(str, 257, im )) return -1;