| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-2.4 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 |
| MIME-Version: | 1.0 |
| In-Reply-To: | <4F33D71A.9040105@gmail.com> |
| References: | <4F33AA60 DOT 6080704 AT gmail DOT com> <20120209123738 DOT GG23330 AT calimero DOT vinschen DOT de> <4F33D71A DOT 9040105 AT gmail DOT com> |
| Date: | Thu, 9 Feb 2012 16:22:23 +0100 |
| Message-ID: | <CAKw7uVg1U06aoCL9xb-x27ztFmOiwACEAf0G55w0V3xzoH5ZRg@mail.gmail.com> |
| Subject: | Re: how to set locale with C++ |
| From: | =?UTF-8?Q?V=C3=A1clav_Zeman?= <vhaisman AT gmail DOT com> |
| To: | cygwin AT cygwin DOT com |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| X-MIME-Autoconverted: | from quoted-printable to 8bit by delorie.com id q19FMjLU032400 |
On 9 February 2012 15:24, marco atzeri wrote:
> On 2/9/2012 1:37 PM, Corinna Vinschen wrote:
>>
>> On Feb  9 12:13, marco atzeri wrote:
>>>
>>> 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 ?
>>
>>
>> This doesn't look like a Cygwin issue. Â The above error
>> "locale::facet::_S_create_c_locale name not valid" points to some
>> problem in the library implementing the locale call. Â The underlying
>> plain C call setlocale should work fine.
>>
>>
>> Corinna
>>
>
> g++ 4.5.3 seems to have a problem on cygwin.
>
> setlocale on pure C is working
> (modified from
> http://www.cplusplus.com/reference/clibrary/clocale/setlocale/)
>
> $ ./setlocale.exe
> Locale is: C
> Date is: Thu Feb  9 14:52:45 2012
> Currency symbol is:
> -
> Locale is: fr_FR.UTF-8
> Date is: jeu.  9 févr. 2012 14:52:45
> Currency symbol is: €
> -
>
>
> Dave,
> it could be related to libstdc++ built with a different
> --enable-clocale option ?
The problem is that Cygwin/newlib does not have good enough locale
support. C99 locale support is not good enough for std::locale
implementation. Mainly because the functions that change the locale
affect the whole process. It is necessary to have at least per thread
locale for std::locale to be implementable; it is better to have some
sort of locale structure to pass around. AFAIK this can be
implemented using functions provided by xlocale.h (MacOS X, [1]).
>
> http://gcc.gnu.org/onlinedocs/libstdc++/manual/build.html
>
> Or that functionality is not available on cygwin ?
[1] <http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/xlocale.3.html>
--
VZ
--
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |