My 2c:<br>I encountered this problem with ParaView, for which I exposed the vtkDICOMImageReader. With french locales, and under linux (fedora 9-11-12), I cannot open a DICOM volume. I changed my language settings to English (UK) and that did the trick. I remember to have such a discussion about ascii writer ( <a href="http://www.mail-archive.com/paraview@paraview.org/msg04621.html">http://www.mail-archive.com/paraview@paraview.org/msg04621.html</a> ).<br>
<br>I will closely follow that thread!<br><br>Jerome<br><br><div class="gmail_quote">2009/11/27 Marcus D. Hanwell <span dir="ltr"><<a href="mailto:marcus.hanwell@kitware.com">marcus.hanwell@kitware.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">This issue hit us on a project I worked on previously. After a quick search a<br>
few relevant pages may help to clear up the situation. I know from an i18n<br>
point of view, and from being a good library (where readers are often called<br>
in separate threads so as not to lock the GUI) we should not set the global<br>
locale.<br>
<br>
Instead the C++ functions and classes should be used in combination with<br>
imbue. See for example,<br>
<br>
<a href="http://stackoverflow.com/questions/1333451/c-locale-independent-atof" target="_blank">http://stackoverflow.com/questions/1333451/c-locale-independent-atof</a><br>
<br>
This means that the C functions such as scanf cannot be used if you are<br>
relying on the imbue functionality.<br>
<font color="#888888"><br>
Marcus<br>
</font><div><div></div><div class="h5"><br>
On Friday 27 November 2009 13:29:29 Francois Bertel wrote:<br>
> Actually, the documentation of setlocale() says that:<br>
><br>
> "<br>
> On startup of the main program, the portable "C" locale is selected as<br>
> default. "<br>
> (this is probably what Markus merely remembered when he said "The C<br>
> functions as I remember set the locale globally")<br>
><br>
> It means that changing the LC_ALL environment variable in a dashboard<br>
> script is pointless.<br>
><br>
> It also means, as stated at the beginning of this discussion (but I<br>
> haven't read it that way) that, in the combination with wx and vtk,<br>
> the wx component is the probably the one forcing the locales to be<br>
> something like:<br>
><br>
> setlocale(LC_ALL, ""); // Make the program portable to all locales<br>
> (LC_NUMERIC, LC_TIME, ...)<br>
><br>
><br>
> So we have to go back to the first approach for regression testing:<br>
> forcing a non English locale at the beginning of the test.<br>
><br>
><br>
> On Fri, Nov 27, 2009 at 1:09 PM, Mathieu Malaterre<br>
><br>
> <<a href="mailto:mathieu.malaterre@gmail.com">mathieu.malaterre@gmail.com</a>> wrote:<br>
> > I do not know for Windows. But for UNIX machine if the fr_FR locale is<br>
> > not installed , I think setlocale() is simply a no-OP. Part of the<br>
> > test should make sure that "," is indeed the LC_NUMERIC separator.<br>
> ><br>
> > 2cts<br>
> ><br>
> > On Fri, Nov 27, 2009 at 7:05 PM, Francois Bertel<br>
> ><br>
> > <<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>> wrote:<br>
> >> Actually, forcing a non English locale in a test is probably the wrong<br>
> >> approach because the locale might not exist on the system.<br>
> >> Instead, it is probably better to change the environment variable on a<br>
> >> dashboard machine.<br>
> >><br>
> >> I just changed the script of arkadia on VTK to run the tests under<br>
> >> French locales, with the following lines:<br>
> >><br>
> >> # save LC_ALL<br>
> >> set(saved_lc_all "$ENV{LC_ALL}")<br>
> >> [...]<br>
> >> # Change locales to make sure the text file readers and writers are<br>
> >> locale independent:<br>
> >> # Before writing the following line, we made sure that "fr_FR.utf8" is<br>
> >> listed in # "locale -a", if not, install package "language-support-fr"<br>
> >> set(ENV{LC_ALL} "fr_FR.utf8")<br>
> >><br>
> >> [...]<br>
> >> ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}")<br>
> >> [...]<br>
> >> # restore LC_ALL<br>
> >> set(ENV{LC_ALL} "${saved_lc_all}")<br>
> >><br>
> >><br>
> >> We'll see how bad is it for VTK tomorrow.<br>
> >><br>
> >><br>
> >> On Fri, Nov 27, 2009 at 12:17 PM, Francois Bertel<br>
> >><br>
> >> <<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>> wrote:<br>
> >>> ... starting with regression tests that do the following:<br>
> >>><br>
> >>> For a text reader:<br>
> >>><br>
> >>> 1. switch to a locale known to be different than English regarding<br>
> >>> numerical rules, like French where "," and "." have opposite meaning.<br>
> >>> 2. read the file (assuming the file to read is encoded in C|POSIX<br>
> >>> locales)<br>
> >>><br>
> >>> For a text writer:<br>
> >>> 1. switch to a non English locale<br>
> >>> 2. write a file<br>
> >>> 3. switch to an English locale<br>
> >>> 4. read the file<br>
> >>><br>
> >>> On Fri, Nov 27, 2009 at 12:07 PM, Bill Lorensen<br>
<<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>> wrote:<br>
> >>>> Looks like we have some work to do in both itk and vtk.<br>
> >>>><br>
> >>>> Bill<br>
> >>>><br>
> >>>> On Fri, Nov 27, 2009 at 12:05 PM, Francois Bertel<br>
> >>>><br>
> >>>> <<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>> wrote:<br>
> >>>>> note: it is necessary to duplicate the return value of setlocale() as<br>
> >>>>> it can be a pointer to a static string.<br>
> >>>>><br>
> >>>>> On Fri, Nov 27, 2009 at 12:04 PM, Francois Bertel<br>
> >>>>><br>
> >>>>> <<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>> wrote:<br>
> >>>>>> Something like that:<br>
> >>>>>><br>
> >>>>>> // save the current locale<br>
> >>>>>> prev_locale = setlocale(LC_NUMERIC, NULL);<br>
> >>>>>> prev_locale = dupstring(setlocale(LC_NUMERIC, NULL));<br>
> >>>>>> setlocale(LC_NUMERIC, "POSIX");<br>
> >>>>>><br>
> >>>>>> <reader code here><br>
> >>>>>><br>
> >>>>>> // Restore locale<br>
> >>>>>> setlocale(LC_NUMERIC, prev_locale);<br>
> >>>>>> if(prev_locale)<br>
> >>>>>> {<br>
> >>>>>> setlocale(LC_NUMERIC, prev_locale);<br>
> >>>>>> }<br>
> >>>>>><br>
> >>>>>> ref: <a href="http://www.zsh.org/mla/workers/2003/msg00210.html" target="_blank">http://www.zsh.org/mla/workers/2003/msg00210.html</a><br>
> >>>>>><br>
> >>>>>> I don't think bug 5891 is relevant as it elimitates the use of<br>
> >>>>>> interpretation of text into numerical values.<br>
> >>>>>> Patch in bug 1431 was using the selocale() function (as above).<br>
> >>>>>><br>
> >>>>>><br>
> >>>>>> On Fri, Nov 27, 2009 at 11:58 AM, Mathieu Malaterre<br>
> >>>>>><br>
> >>>>>> <<a href="mailto:mathieu.malaterre@gmail.com">mathieu.malaterre@gmail.com</a>> wrote:<br>
> >>>>>>> On Fri, Nov 27, 2009 at 5:57 PM, Marcus D. Hanwell<br>
> >>>>>>><br>
> >>>>>>> <<a href="mailto:marcus.hanwell@kitware.com">marcus.hanwell@kitware.com</a>> wrote:<br>
> >>>>>>>> The C functions as I remember set the locale globally which can<br>
> >>>>>>>> also cause unexpected bugs if a library changes this internally.<br>
> >>>>>>><br>
> >>>>>>> Ah ! That answer my question :)<br>
> >>>>>>><br>
> >>>>>>> Thx<br>
> >>>>>>> --<br>
> >>>>>>> Mathieu<br>
> >>>>>>> _______________________________________________<br>
> >>>>>>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
> >>>>>>><br>
> >>>>>>> Visit other Kitware open-source projects at<br>
> >>>>>>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
> >>>>>>><br>
> >>>>>>> Please keep messages on-topic and check the VTK FAQ at:<br>
> >>>>>>> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
> >>>>>>><br>
> >>>>>>> Follow this link to subscribe/unsubscribe:<br>
> >>>>>>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
> >>>>>><br>
> >>>>>> --<br>
> >>>>>> François Bertel, PhD | Kitware Inc. Suite 204<br>
> >>>>>> 1 (518) 371 3971 x113 | 28 Corporate Drive<br>
> >>>>>> | Clifton Park NY 12065, USA<br>
> >>>>><br>
> >>>>> --<br>
> >>>>> François Bertel, PhD | Kitware Inc. Suite 204<br>
> >>>>> 1 (518) 371 3971 x113 | 28 Corporate Drive<br>
> >>>>> | Clifton Park NY 12065, USA<br>
> >>>>> _______________________________________________<br>
> >>>>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
> >>>>><br>
> >>>>> Visit other Kitware open-source projects at<br>
> >>>>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
> >>>>><br>
> >>>>> Please keep messages on-topic and check the VTK FAQ at:<br>
> >>>>> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
> >>>>><br>
> >>>>> Follow this link to subscribe/unsubscribe:<br>
> >>>>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
> >>><br>
> >>> --<br>
> >>> François Bertel, PhD | Kitware Inc. Suite 204<br>
> >>> 1 (518) 371 3971 x113 | 28 Corporate Drive<br>
> >>> | Clifton Park NY 12065, USA<br>
> >><br>
> >> --<br>
> >> François Bertel, PhD | Kitware Inc. Suite 204<br>
> >> 1 (518) 371 3971 x113 | 28 Corporate Drive<br>
> >> | Clifton Park NY 12065, USA<br>
> >> _______________________________________________<br>
> >> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
> >><br>
> >> Visit other Kitware open-source projects at<br>
> >> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
> >><br>
> >> Please keep messages on-topic and check the VTK FAQ at:<br>
> >> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
> >><br>
> >> Follow this link to subscribe/unsubscribe:<br>
> >> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
> ><br>
> > --<br>
> > Mathieu<br>
><br>
<br>
--<br>
</div></div><div class="im">Marcus D. Hanwell, Ph.D.<br>
R&D Engineer, Kitware Inc.<br>
(518) 881-4937<br>
_______________________________________________<br>
</div><div><div></div><div class="h5">Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br>