Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#588 Make non-Trivial Locales work

OTHER
closed
Earnie Boyd
out-of-date
Unknown
2013-02-04
2004-06-10
Paul
No

The i18n & l10n in MinGW seem not to work compared
with their same unix version build.

They really don't seem to work at all on Windows 2000
for non-trivial locales.

Here is a money_get example that works on unix but not
on MinGW:
#include <locale>
#include <string>
#include <sstream>
#include <iostream>

using namespace std;

namespace {

void doit(const string& amount)
{
// Use a non-trivial locale by setting
LANG=en_US.UTF8 (for
// example).
istringstream istrm(amount);
istrm.imbue(locale(""));

// Retrieve the money_get facet.
const money_get<char>& mgf =
use_facet< money_get <char> >(istrm.getloc
());

// Use the facet to extract the amount from istrm.
string extracted_amount;
ios_base::iostate err = ios_base::iostate(0);
mgf.get(istrm, 0, false, istrm, err,
extracted_amount);

// Check for errors.
if( err & ios_base::failbit ) {
extracted_amount = "<error>";
}

// What did we get?
cout << "amount = " << extracted_amount <<
endl;
}

}

int main(int argc, char* argv[])
{
int rv = 0;
doit("$.05");
doit("$.04");
doit("$.03");
doit("$.02");
doit("$.01");

return rv;
}

// Windows results in:
amount = <error>
amount = <error>
amount = <error>
amount = <error>
amount = <error>

// Linux results in
amount = 5
amount = 4
amount = 3
amount = 2
amount = 1

money_put seems like it should be easier than
money_get and it has just as many problems.

Reference bug: 969845

Discussion

  • Earnie Boyd
    Earnie Boyd
    2013-02-04

    • labels: MinGW --> gcc, g++, locale
    • status: open --> closed
    • resolution: --> out-of-date
    • category: --> Unknown
    • milestone: Feature_requests --> OTHER