This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Need Guidance: Porting locales, wide character specializations


Hi,

AaronWL wrote:
> I'm interested in getting libstdc++-v3's wide character 
> specializations
> (std::wcout etc), as well as general locale stuff, working on 
> my system
> (win32).

I'm trying to do some of the same on Linux. Maybe I can give you some
hints on where to start.

> The things configure seems to want to enable wchar: fairly 
> complete support
> of c99 <wchar.h>, iconv, and langinfo.  Getting the first is simple
> enough, but what about iconv and langinfo?  Win32 does not 
> have a native
> notion of either.  While GNU libiconv works for win32, there is no
> drop-in version of langinfo (which apparently is tied to the C library
> [it bugs me how unix does not distinguish between the C library and
> the rest of the OS]).  I'm assuming all of this stuff is needed by the
> codecvt facet (although, honestly, it seems a bit excessive :( )

Well, Win32 does have GetLocaleInfo, which seems to do the same
as nl_langinfo, although with a slightly different interface and
different names for the constants.

Anyway, iconv and nl_langinfo are not used by
std::codecvt<wchar_t, char, std::mbstate_t> (which is the version of
codecvt used by std::wcout). They are however used by the partial
specialization std::codecvt<I, E, std::__enc_traits>, but IIRC it is
possible to build the rest of the library without iconv.

> I'm wondering what the 'right' way would be to get wchar (and the rest of
> my locales) working on my system.  Specifically, I am interested in
> correctness, but also in quality of implementation and reusability.
> Eg, I'd like to be able to have std::codecvt use my installed
> windows codepages, and std::time_put reflect what I specify in the
> windows control panel.

If you want correct, you will probably need to implement
codecvt<wchar_t, char, mbstate_t> (and possibly other facets) for
your system using the native API. The facet implementations used
on Linux use unportable constructs (such as nl_langinfo) to achieve
correctness; I find it likely that the same is neccessary for other
systems as well.

> Any guidance or references or pointers or explainations would be
> appreciated.

Hope this helps,
Petur


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]