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">&lt;<a href="mailto:marcus.hanwell@kitware.com">marcus.hanwell@kitware.com</a>&gt;</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>
&gt; Actually, the documentation of setlocale() says that:<br>
&gt;<br>
&gt; &quot;<br>
&gt; On startup of the main program, the portable &quot;C&quot; locale is selected as<br>
&gt;  default. &quot;<br>
&gt; (this is probably what Markus merely remembered when he said &quot;The C<br>
&gt; functions as I remember set the locale globally&quot;)<br>
&gt;<br>
&gt; It means that changing the LC_ALL environment variable in a dashboard<br>
&gt; script is pointless.<br>
&gt;<br>
&gt; It also means, as stated at the beginning of this discussion (but I<br>
&gt; haven&#39;t read it that way) that, in the combination with wx and vtk,<br>
&gt; the wx component is the probably the one forcing the locales to be<br>
&gt; something like:<br>
&gt;<br>
&gt;  setlocale(LC_ALL, &quot;&quot;); // Make the program portable to all locales<br>
&gt; (LC_NUMERIC, LC_TIME, ...)<br>
&gt;<br>
&gt;<br>
&gt; So we have to go back to the first approach for regression testing:<br>
&gt; forcing a non English locale at the beginning of the test.<br>
&gt;<br>
&gt;<br>
&gt; On Fri, Nov 27, 2009 at 1:09 PM, Mathieu Malaterre<br>
&gt;<br>
&gt; &lt;<a href="mailto:mathieu.malaterre@gmail.com">mathieu.malaterre@gmail.com</a>&gt; wrote:<br>
&gt; &gt; I do not know for Windows. But for UNIX machine if the fr_FR locale is<br>
&gt; &gt; not installed , I think setlocale() is simply a no-OP. Part of the<br>
&gt; &gt; test should make sure that &quot;,&quot; is indeed the LC_NUMERIC separator.<br>
&gt; &gt;<br>
&gt; &gt; 2cts<br>
&gt; &gt;<br>
&gt; &gt; On Fri, Nov 27, 2009 at 7:05 PM, Francois Bertel<br>
&gt; &gt;<br>
&gt; &gt; &lt;<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>&gt; wrote:<br>
&gt; &gt;&gt; Actually, forcing a non English locale in a test is probably the wrong<br>
&gt; &gt;&gt; approach because the locale might not exist on the system.<br>
&gt; &gt;&gt; Instead, it is probably better to change the environment variable on a<br>
&gt; &gt;&gt; dashboard machine.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; I just changed the script of arkadia on VTK to run the tests under<br>
&gt; &gt;&gt; French locales, with the following lines:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; # save LC_ALL<br>
&gt; &gt;&gt; set(saved_lc_all &quot;$ENV{LC_ALL}&quot;)<br>
&gt; &gt;&gt; [...]<br>
&gt; &gt;&gt; # Change locales to make sure the text file readers and writers are<br>
&gt; &gt;&gt; locale independent:<br>
&gt; &gt;&gt; # Before writing the following line, we made sure that &quot;fr_FR.utf8&quot; is<br>
&gt; &gt;&gt; listed in # &quot;locale -a&quot;, if not, install package &quot;language-support-fr&quot;<br>
&gt; &gt;&gt; set(ENV{LC_ALL} &quot;fr_FR.utf8&quot;)<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; [...]<br>
&gt; &gt;&gt; ctest_test(BUILD &quot;${CTEST_BINARY_DIRECTORY}&quot;)<br>
&gt; &gt;&gt; [...]<br>
&gt; &gt;&gt; # restore LC_ALL<br>
&gt; &gt;&gt; set(ENV{LC_ALL} &quot;${saved_lc_all}&quot;)<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; We&#39;ll see how bad is it for VTK tomorrow.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; On Fri, Nov 27, 2009 at 12:17 PM, Francois Bertel<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; &lt;<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>&gt; wrote:<br>
&gt; &gt;&gt;&gt; ... starting with regression tests that do the following:<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; For a text reader:<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; 1. switch to a locale known to be different than English regarding<br>
&gt; &gt;&gt;&gt; numerical rules, like French where &quot;,&quot; and &quot;.&quot; have opposite meaning.<br>
&gt; &gt;&gt;&gt; 2. read the file (assuming the file to read is encoded in C|POSIX<br>
&gt; &gt;&gt;&gt; locales)<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; For a text writer:<br>
&gt; &gt;&gt;&gt; 1. switch to a non English locale<br>
&gt; &gt;&gt;&gt; 2. write a file<br>
&gt; &gt;&gt;&gt; 3. switch to an English locale<br>
&gt; &gt;&gt;&gt; 4. read the file<br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; On Fri, Nov 27, 2009 at 12:07 PM, Bill Lorensen<br>
&lt;<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>&gt; wrote:<br>
&gt; &gt;&gt;&gt;&gt; Looks like we have some work to do in both itk and vtk.<br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; Bill<br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; On Fri, Nov 27, 2009 at 12:05 PM, Francois Bertel<br>
&gt; &gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt; &lt;<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>&gt; wrote:<br>
&gt; &gt;&gt;&gt;&gt;&gt; note: it is necessary to duplicate the return value of setlocale() as<br>
&gt; &gt;&gt;&gt;&gt;&gt; it can be a pointer to a static string.<br>
&gt; &gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt; On Fri, Nov 27, 2009 at 12:04 PM, Francois Bertel<br>
&gt; &gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt; &lt;<a href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>&gt; wrote:<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; Something like that:<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; // save the current locale<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;  prev_locale = setlocale(LC_NUMERIC, NULL);<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;  prev_locale = dupstring(setlocale(LC_NUMERIC, NULL));<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; setlocale(LC_NUMERIC, &quot;POSIX&quot;);<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; &lt;reader code here&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; // Restore locale<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; setlocale(LC_NUMERIC, prev_locale);<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; if(prev_locale)<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; {<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;  setlocale(LC_NUMERIC, prev_locale);<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; }<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; 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>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; I don&#39;t think bug 5891 is relevant as it elimitates the use of<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; interpretation of text into numerical values.<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; Patch in bug 1431 was using the selocale() function (as above).<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; On Fri, Nov 27, 2009 at 11:58 AM, Mathieu Malaterre<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; &lt;<a href="mailto:mathieu.malaterre@gmail.com">mathieu.malaterre@gmail.com</a>&gt; wrote:<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; On Fri, Nov 27, 2009 at 5:57 PM, Marcus D. Hanwell<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;<a href="mailto:marcus.hanwell@kitware.com">marcus.hanwell@kitware.com</a>&gt; wrote:<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; The C functions as I remember set the locale globally which can<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; also cause unexpected bugs if a library changes this internally.<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Ah ! That answer my question :)<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Thx<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; --<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Mathieu<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Visit other Kitware open-source projects at<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Please keep messages on-topic and check the VTK FAQ at:<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; --<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; François Bertel, PhD  | Kitware Inc. Suite 204<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt; 1 (518) 371 3971 x113 | 28 Corporate Drive<br>
&gt; &gt;&gt;&gt;&gt;&gt;&gt;                      | Clifton Park NY 12065, USA<br>
&gt; &gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt; --<br>
&gt; &gt;&gt;&gt;&gt;&gt; François Bertel, PhD  | Kitware Inc. Suite 204<br>
&gt; &gt;&gt;&gt;&gt;&gt; 1 (518) 371 3971 x113 | 28 Corporate Drive<br>
&gt; &gt;&gt;&gt;&gt;&gt;                      | Clifton Park NY 12065, USA<br>
&gt; &gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt; &gt;&gt;&gt;&gt;&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt; &gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt; Visit other Kitware open-source projects at<br>
&gt; &gt;&gt;&gt;&gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt; &gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt; Please keep messages on-topic and check the VTK FAQ at:<br>
&gt; &gt;&gt;&gt;&gt;&gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt; &gt;&gt;&gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt;&gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; &gt;&gt;&gt;&gt;&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt; &gt;&gt;&gt;<br>
&gt; &gt;&gt;&gt; --<br>
&gt; &gt;&gt;&gt; François Bertel, PhD  | Kitware Inc. Suite 204<br>
&gt; &gt;&gt;&gt; 1 (518) 371 3971 x113 | 28 Corporate Drive<br>
&gt; &gt;&gt;&gt;                      | Clifton Park NY 12065, USA<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; --<br>
&gt; &gt;&gt; François Bertel, PhD  | Kitware Inc. Suite 204<br>
&gt; &gt;&gt; 1 (518) 371 3971 x113 | 28 Corporate Drive<br>
&gt; &gt;&gt;                      | Clifton Park NY 12065, USA<br>
&gt; &gt;&gt; _______________________________________________<br>
&gt; &gt;&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Visit other Kitware open-source projects at<br>
&gt; &gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Please keep messages on-topic and check the VTK FAQ at:<br>
&gt; &gt;&gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; &gt;&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; Mathieu<br>
&gt;<br>
<br>
--<br>
</div></div><div class="im">Marcus D. Hanwell, Ph.D.<br>
R&amp;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>