zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <zefram@fysh.org>
To: schaefer@candle.brasslantern.com (Bart Schaefer)
Cc: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: math and locale
Date: Mon, 22 Nov 1999 20:03:39 +0000 (GMT)	[thread overview]
Message-ID: <E11pzgZ-00082P-00@crucigera.fysh.org> (raw)
In-Reply-To: <991122182320.ZM22621@candle.brasslantern.com> from Bart Schaefer at "Nov 22, 1999  6:23:20 pm"

Bart Schaefer wrote:
>Glancing through /usr/X11R6/lib/X11/locale/locale.alias I see that the
>"POSIX" locale is an alias for the "C" locale, so it probably doesn't
>really matter either way.  Anyone else have an opinion?  Zefram, perhaps?

Well since you asked...

"C" is probably to be preferred, because it will be available in *all*
locale implementations, whereas the "POSIX" locale is a POSIXism.
However, where the locale is already "POSIX", presumably we wouldn't need
to change that, if we're making setting it conditional -- I don't have
the standard to hand, but I'd be very surprised if it defined a different
numeric form.  Data point: setlocale(3) on Linux indicates that "C" and
"POSIX" are canonically equivalent.

>} > Where *exactly* would LC_NUMERIC make any difference in pws-9 ?

Here we run into one of the big conceptual problems with locales.
Are we outputting human text or machine data?  There's a need for both.
locale-aware programs need to consider which category each output
falls into, and perform conversions appropriately.  Unfortunately, the
C locale system provides no way to switch locale on a per-conversion
basis -- not even separate interfaces to perform conversions in the "C"
and current locales.  This is where it all falls down, and programmers
like me just throw up our hands and give up until we're provided with a
usable interface.

If we do wish zsh itself to use locales, I see several possibilities:

* We can do what POSIX defines for most utilities (not sure what it
  says about sh): guarantee sensible behaviour in the "POSIX" locale,
  and leave it undefined everywhere else.  Strictly speaking, if you
  want the standard form of output from most POSIX utilities, you have
  to set LC_ALL=POSIX for it.

* We can use the selected locale for LC_MESSAGES, which only affects
  things that are definitely for human consumption, and leave everything
  else using the "C" locale.  This would have almost exactly the desired
  effect for zsh, and is trivially easy to implement.

* We can try to do it properly: decide which things should be
  locale-dependent and which shouldn't.  We can fabricate a set of
  functions like glibc's strtod_l() (perform strtod() using locale X)
  to make it easier.  Problem: we'd get ambiguous cases.  strftime()
  is particularly nasty in this respect.  However, following this path,
  we could make the whole locale thing much easier for the users of zsh:
  we could provide interfaces where the user specifies whether to use
  locales or not.  ztrftime() could allow a flag in % sequences to say
  "use the "C" locale for this expansion".

Opinions?

-zefram


  parent reply	other threads:[~1999-11-22 20:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-20 20:18 Clint Adams
1999-11-20 20:53 ` Bart Schaefer
1999-11-21 18:14   ` Clint Adams
1999-11-22  8:17     ` Bart Schaefer
1999-11-22 14:42       ` Clint Adams
1999-11-22 18:23         ` Bart Schaefer
1999-11-22 19:36           ` Clint Adams
1999-11-22 20:03           ` Zefram [this message]
1999-11-23 18:18             ` Bart Schaefer
1999-11-26 22:08             ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E11pzgZ-00082P-00@crucigera.fysh.org \
    --to=zefram@fysh.org \
    --cc=schaefer@candle.brasslantern.com \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).