unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Kevin Ryde <user42@zip.com.au>
Subject: Re: Text collation
Date: Tue, 05 Dec 2006 11:38:04 +1100	[thread overview]
Message-ID: <87k617kwib.fsf@zip.com.au> (raw)
In-Reply-To: <87zma9m07p.fsf@laas.fr> (Ludovic Courtès's message of "Thu, 30 Nov 2006 16:19:06 +0100")

[-- Attachment #1: Type: text/plain, Size: 833 bytes --]

ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>
> I've written a wrapper for `nl_langinfo ()' as part of the `i18n' module

What do other schemes or lisps do?  I had an idea one of the srfis had
some bits but they weren't great.  I started a localeconv bit (below)
using a vector for all info, though I'm now inclined to think a
function with a symbol arg would be friendlier than a big object
return.

	(langinfo 'thousands-sep) => ","

Or "localeinfo" or "localeconv" or something.

In my charting program I made a separate function for each of the few
bits I wanted,

	(locale-decimal-point) => "."
	(locale-d-fmt)         => "%d/%m/%y"

One cute thing about that is that the user can override to personal
preferences by `set!'ing in a new function, like having "%b" for the
month in the date format.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: localeconv.c --]
[-- Type: text/x-csrc, Size: 2416 bytes --]

#define _GNU_SOURCE  /* ask glibc for C99 lconv fields */

#include <locale.h>




SCM_DEFINE (scm_localeconv, "localeconv", 0, 0, 0,
            (),
	    "Return an ``lconv'' object representing current locale specific\n"
	    "information.")
#define FUNC_NAME s_scm_localtime
{
  SCM result;
  const struct lconv *l;

#define LCONV_STR(idx, field)                                   \
  SCM_VECTOR_SET (result, idx, scm_makfrom0str (l->field))

#define LCONV_INT(idx, field)                           \
  SCM_VECTOR_SET (result, idx, SCM_MAKINUM (l->field))

  /* group array ends with either 0 or CHAR_MAX */
#define LCONV_GRP(idx, field)                                           \
  do {                                                                  \
    SCM  vec;                                                           \
    int  n, i;                                                          \
    for (i = 0; l->field[i] != 0 && l->field[i] != CHAR_MAX; i++)       \
      ;                                                                 \
    n = i + 1;  /* number of elements */                                \
    vec = scm_c_make_vector (n, SCM_BOOL_F);                            \
    for (i = 0; i < n; i++)                                             \
      SCM_VECTOR_SET (result, idx, SCM_MAKINUM (l->field[i]));          \
    SCM_VECTOR_SET (result, idx, vec);                                  \
  } while (0)

  result = scm_c_make_vector (11, SCM_BOOL_F);

  SCM_DEFER_INTS;
  LCONV_STR ( 0, decimal_point);
  LCONV_STR ( 1, thousands_sep);
  LCONV_GRP ( 2, grouping);
  LCONV_STR ( 3, int_curr_symbol);
  LCONV_STR ( 4, currency_symbol);
  LCONV_STR ( 5, mon_decimal_point);
  LCONV_STR ( 6, mon_thousands_sep);
  LCONV_GRP ( 7, mon_grouping);
  LCONV_STR ( 8, positive_sign);
  LCONV_STR ( 9, negative_sign);
  LCONV_INT (10, int_frac_digits);
  LCONV_INT (11, frac_digits);
  LCONV_INT (12, p_cs_precedes);
  LCONV_INT (13, p_sep_by_space);
  LCONV_INT (14, n_cs_precedes);
  LCONV_INT (15, n_sep_by_space);
  LCONV_INT (16, p_sign_posn);
  LCONV_INT (17, n_sign_posn);

  /* C99 extras, apparently */
#if HAVE_LCONV_INT_P_CS_PRECEDES
  LCONV_INT (18, int_p_cs_precedes);
  LCONV_INT (19, int_p_sep_by_space);
  LCONV_INT (20, int_n_cs_precedes);
  LCONV_INT (21, int_n_sep_by_space);
  LCONV_INT (22, int_p_sign_posn);
  LCONV_INT (23, int_n_sign_posn);
#endif

  return result;
}

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

  parent reply	other threads:[~2006-12-05  0:38 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-19  9:23 Text collation Ludovic Courtès
2006-09-19 22:38 ` Kevin Ryde
2006-10-22 18:33   ` Ludovic Courtès
2006-10-23  2:01     ` Rob Browning
2006-10-23  7:56       ` Ludovic Courtès
2006-10-24  8:37         ` Rob Browning
2006-10-25  8:16           ` Ludovic Courtès
2006-10-25  8:46             ` Rob Browning
2006-10-25 18:40               ` Neil Jerram
2006-10-25 19:55                 ` Rob Browning
2006-10-26  8:47                 ` Ludovic Courtès
2006-11-09  7:44                   ` Ludovic Courtès
2006-11-09 17:43                     ` Rob Browning
2006-11-10 13:39                       ` Ludovic Courtès
2006-11-11 15:17                         ` Neil Jerram
2006-11-20 13:24                         ` Ludovic Courtès
2006-11-21 22:03                           ` Neil Jerram
2006-11-22 13:38                             ` Ludovic Courtès
2006-10-25 18:43           ` Neil Jerram
2006-10-25 19:31             ` Rob Browning
2006-10-25 18:33     ` Neil Jerram
2006-10-26  8:39       ` Ludovic Courtès
2006-11-29 23:08     ` Kevin Ryde
2006-11-30 15:19       ` Ludovic Courtès
2006-12-02 21:56         ` Kevin Ryde
2006-12-04  9:01           ` Ludovic Courtès
2006-12-05  0:20             ` Kevin Ryde
2006-12-05 18:42               ` Carl Witty
2006-12-05 20:41                 ` Kevin Ryde
2006-12-05 22:29                   ` Carl Witty
2006-12-05  0:38         ` Kevin Ryde [this message]
2006-12-02 22:02       ` Kevin Ryde
2006-12-10 12:30       ` Ludovic Courtès
2006-12-11 22:32         ` Kevin Ryde
2006-12-12  8:38           ` Ludovic Courtès
2006-12-12 20:04             ` Kevin Ryde
2006-12-13  9:41               ` Ludovic Courtès
2006-12-31 17:10               ` Neil Jerram
2006-12-15 20:52             ` Kevin Ryde
2006-12-12 19:05     ` Kevin Ryde
2006-12-13  9:14       ` Ludovic Courtès
2006-12-12 19:16     ` Kevin Ryde
2006-12-13  9:20       ` Ludovic Courtès
2006-12-12 21:37     ` Kevin Ryde
2006-12-13  9:28       ` Ludovic Courtès
2006-12-13 20:10         ` Kevin Ryde

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=87k617kwib.fsf@zip.com.au \
    --to=user42@zip.com.au \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).