tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: curses vs non-ASCII

>Are these two things - (a) that setlocale() has to be called for the
>environment to be recognized and (b) that "" is magic to make it pick
>up the environment - documented anywhere?  The closest I see is a line
>in locale(3) that says that "" `denotes the native environment', but
>without any description of what that means; I'm wondering if I've just
>missed something.

I found the documentation provided by the Open Group had a better overview,
which I found here:

Specifically, it says that to get the various locale-aware functions to pay
attention to the locale settings you need to call setlocale(), and it
specifically mentions that "" means "the value of the corresponding
environment is used".  The system man pages are ... not wonderful.

>Is there any documentation on what strings can be put in $LANG et al?
>I guessed en_CA.ISO8859-1 based on the da_DK.ISO8859-1 example in
>nls(7), but doing that seems...suboptimal.

Sigh.  As far as I can tell, locale names are not standardized in any
way, but they seem to mostly follow the convention of:


But you should be able to get a list of all supported locales via 'locale -a',
and you can make some intelligent guesses from there.  The document above
says that if the environment variable contains a '/', it should be a
pathname to a locale file so you should be able to use a custom one
rather easily.

>Is there any documentation for someone wanting to create a locale?  It
>seems likely to me that there aren't any existing locales that consider
>all of 0x20-0xff as printable, in which case the least-pain option may
>be to create a locale of my own.  (The latest attempt at building a
>system without these headaches produced _compile_ errors in vi.  I
>can't help wondering why the knobs even exist if attempts to use them
>explode this badly.)

The web page I listed above describes the input to localedef(1), which
I think is what you want.  Somewhere in the source code should be the
various inputs to localedef(1), so you could easily take one of those
and adjust them for your needs.

I think those compilation knobs are probably left over from when POSIX
locale support was not widespread.  Classic bitrot.  We ran into similar
issues with nmh; at some point I just yanked out all of the #ifdef
LOCALE lines, as it wasn't worth trying to support systems that didn't
have locale support.


Home | Main Index | Thread Index | Old Index