title: How to parse numbers like "3.14" with scanf when locale expects "3,14"
body: <p>Let's say I have to read a file, containing a bunch of floating-point numbers. The numbers can be like <code>1e+10</code>, <code>5</code>, <code>-0.15</code> etc., i.e., any generic floating-point number, using decimal points (<em>this is fixed!</em>). However, my code is a plugin for another application, and I have no control over what's the current locale. It may be Russian, for example, and the LC_NUMERIC rules there call for a decimal <em>comma</em> to be used. Thus, Pi is expected to be spelled as &quot;3,1415...&quot;, and</p>
  <pre><code>sscanf(&quot;3.14&quot;, &quot;%f&quot;, &amp;x); 
  </code></pre>
  <p>returns &quot;1&quot;, and x contains &quot;3.0&quot;, since it refuses to parse past the '.' in the string.</p>
  <p>I need to ignore the locale for such number-parsing tasks.</p>
  <p>How does one do that?</p>
  <p>I could write a parseFloat function, but this seems like a waste.<br />
  I could also save the current locale, reset it temporarily to &quot;C&quot;, read the file, and restore to the saved one. What are the performance implications of this? Could setlocale() be very slow on some OS/libc combo, what does it really do under the hood?<br />
  Yet another way would be to use iostreams, but again their performance isn't stellar.</p>