X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Message-ID: <4F33AA60.6080704@gmail.com> Date: Thu, 09 Feb 2012 12:13:36 +0100 From: marco atzeri User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20120129 Thunderbird/10.0 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: how to set locale with C++ Content-Type: multipart/mixed; boundary="------------040306000207050009090105" X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --------------040306000207050009090105 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Attached a small example taken from Bruce Eckel Thinking in C++ On cygwin both this call cout.imbue(locale("en_US.UTF-8")); cout.imbue(locale("fr_FR.UTF-8")); raise exception "terminate called after throwing an instance of 'std::runtime_error' what(): locale::facet::_S_create_c_locale name not valid Aborted (core dumped)" I could understand eventually the second one, but "English (US)" is the current windows locale so I expected that at least "en_US.UTF-8" is accepted. What I am missing ? Regards Marco --------------040306000207050009090105 Content-Type: text/plain; name="Locale.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="Locale.cpp" //: C04:Locale.cpp {-g++}{-bor}{-edg} {RunByHand} // Illustrates effects of locales. #include #include using namespace std; int main() { locale def; cout << def.name() << endl; locale current = cout.getloc(); cout << current.name() << endl; float val = 1234.56; cout << val << endl; // Change to US cout.imbue(locale("en_US.UTF-8")); current = cout.getloc(); cout << current.name() << endl; cout << val << endl; // Change to French/France cout.imbue(locale("fr_FR.UTF-8")); current = cout.getloc(); cout << current.name() << endl; cout << val << endl; cout << "Enter the literal 7890,12: "; cin.imbue(cout.getloc()); cin >> val; cout << val << endl; cout.imbue(def); cout << val << endl; } ///:~ --------------040306000207050009090105 Content-Type: text/plain; charset=us-ascii -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --------------040306000207050009090105--