title: PowerShell, formatting values in another culture
body: <p>Is there an easy way in PowerShell to format numbers and the like in another locale? I'm currently writing a few functions to ease SVG generation for me and SVG uses <code>.</code> as a decimal separator, while PowerShell honors my locale settings (<code>de-DE</code>) when converting floating-point numbers to strings.</p>
  
  <p>Is there an easy way to set another locale for a function or so without sticking</p>
  
  <pre><code>.ToString((New-Object Globalization.CultureInfo ""))
  </code></pre>
  
  <p>after every <code>double</code> variable?</p>
  
  <p>Note: This is about the <em>locale</em> used for formatting, <em>not</em> the format string.</p>
  
  <p>(Side question: Should I use the invariant culture in that case or rather <code>en-US</code>?)</p>
  
  <p><strong>ETA:</strong> Well, what I'm trying here is something like the following:</p>
  
  <pre><code>function New-SvgWave([int]$HalfWaves, [double]$Amplitude, [switch]$Upwards) {
      "&lt;path d='M0,0q0.5,{0} 1,0{1}v1q-0.5,{2} -1,0{3}z'/&gt;" -f (
          $(if ($Upwards) {-$Amplitude} else {$Amplitude}),
          ("t1,0" * ($HalfWaves - 1)),
          $(if ($Upwards -xor ($HalfWaves % 2 -eq 0)) {-$Amplitude} else {$Amplitude}),
          ("t-1,0" * ($HalfWaves - 1))
      )
  }
  </code></pre>
  
  <p>Just a little automation for stuff I tend to write all the time and the double values need to use the decimal point instead of a comma (which they use in my locale).</p>
  
  <p><strong>ETA2:</strong> Interesting trivia to add:</p>
  
  <pre><code>PS Home:&gt; $d=1.23
  PS Home:&gt; $d
  1,23
  PS Home:&gt; "$d"
  1.23
  </code></pre>
  
  <p>By putting the variable into a string the set locale doesn't seem to apply, somehow.</p>