This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

Re: LC_MESSAGES problem ?




Ulrich Drepper wrote:
> wkpark <wkpark@chem.skku.ac.kr> writes:
> > with utf8 locale(like ko_KR.utf8), does automatic translation working correct
> > with setlocale(LC_MESSAGES,"") only program ??
> Of course not because you are not using the locale.  Using a locale
> means using all of the categories.  As Paul already explained, mixing
> categories from different locales is possible but the behavior is
> undefined.  Especially the LC_CTYPE category must always match the the
> categories you are using.
> >         errno=2;
> > //        setlocale(LC_CTYPE, "");
> >         setlocale(LC_MESSAGES, "");
> >         perror("aaa");
> >         return 1;
> > }
> This program could do whatever it wants, start nethack, format your
> harddisk, whatever.  Its behavior is undefined.

Well, not really undefined, but very hard to get right. The SUSv2 example for
setlocale() shows:
-----
The following code illustrates how a program can initialise the international
environment for one language, while selectively modifying the program's 
locale such that regular expressions and string operations can be applied 
to text recorded in a different language: 

       setlocale(LC_ALL, "De");
       setlocale(LC_COLLATE, "Fr@dict");

Internationalised programs must call setlocale() to initiate a specific language
operation. This can be done by calling setlocale() as follows: 

       setlocale(LC_ALL, "");

Changing the setting of LC_MESSAGES has no effect on catalogues that have 
already been opened by calls to catopen().
------

The point is, you have to set all the categories to what you want them to
be, not just one category and leave the others as default -- you won't
like the results (obviously!).


-- 
Mark S. Brown                                                   bmark@us.ibm.com
Senior Technical Staff Member                          512.838.3926  T/L678.3926
IBM RS/6000 AIX System Architecture                        Mark Brown/Austin/IBM
IBM Corporation, Austin, Texas

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