0

Has anyone ever seen a program use the Windows OS native locale by default instead of 'C' locale (the program is C++)?

I have a C++ program which, when converting a double into a string, will replace all decimal symbols (which were originally points) with a comma.

I can only reproduce this behavior if I insert the below code into the program

char* cpSettings =  std::setlocale(LC_ALL, ""); // use native locale (Spanish), not C

However, the version of this program/software, which is changing point to comma (for decimal symbol) did Not have this line of code in it and therefore should, by default, use a c-locale.

This program only converts points to commas (decimal symbol) when converting double to string on one specific computer.

I assumed this has to do with locale, but even when the locale on the messed up machine is changed back to English (which uses point for decimal), the program will still replace point with comma in a double to string conversion.

Question: I am wondering if anyone has seen this behavior before? Does anyone know what could be causing this behavior?

Fractal
  • 1,748
  • 5
  • 26
  • 46
  • 1
    This is a good question, and it is addressed ***[here](http://stackoverflow.com/questions/12373341/does-stdlocaleglobal-make-affect-to-printf-function)***. – ryyker Oct 15 '14 at 19:37
  • Thanks ryyker. If this was written as an answer I would mark it as the answer. If I do not use setlocale at all in the program, shouldn't a C++ program use the c-locale by default? – Fractal Oct 15 '14 at 20:14
  • The specific command converting point to comma (for decimal symbol) is the vsprintf command – Fractal Oct 15 '14 at 20:19
  • 1
    The second answer in that link has an interesting comment about the different behavior of C & C++. See if that helps at all. ( `setlocale(LC_NUMERIC, "POSIX");` ) And I realize you have tagged windows, but the example may still be relevant. take a look – ryyker Oct 15 '14 at 20:20

0 Answers0