mardi 21 août 2018

C++ std::locale("en") throws exception on iOS

On iOS, when I try to construct a C++ locale from a valid identifier, my program crashes:

Terminating app due to uncaught exception 'collate_byname::collate_byname failed to construct for en', reason: 'collate_byname::collate_byname failed to construct for en'

at this line:

std::locale loc("en");

This works fine on other platforms. And this is a valid locale identifier that exists on the platform (I tried with the identifier that comes from CFLocale).

I need a C++ std::locale for my program in order to format dates and numbers for example.

Maybe I need to include other libraries in the build?

I am using the latest XCode 9.4.1 and its included libc++, this runs on iOS 11.4.1. Other C++ features work fine in there.

Unfortunately there is no way to list the available locales with portable C++, although all those I tried were listed in NSLocale.availableLocaleIdentifiers

Aucun commentaire:

Enregistrer un commentaire