From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: Re: More i18n Date: Tue, 12 Dec 2006 10:26:17 +1100 Message-ID: <87ac1uhv52.fsf@zip.com.au> References: <877iwzokpz.fsf@chbouib.org> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1165879598 25278 80.91.229.10 (11 Dec 2006 23:26:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 11 Dec 2006 23:26:38 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Dec 12 00:26:36 2006 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GtuXc-0002Pi-41 for guile-devel@m.gmane.org; Tue, 12 Dec 2006 00:26:36 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GtuXb-0006kZ-Gd for guile-devel@m.gmane.org; Mon, 11 Dec 2006 18:26:35 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GtuXU-0006jM-LD for guile-devel@gnu.org; Mon, 11 Dec 2006 18:26:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GtuXR-0006gY-IL for guile-devel@gnu.org; Mon, 11 Dec 2006 18:26:28 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GtuXR-0006gE-9b for guile-devel@gnu.org; Mon, 11 Dec 2006 18:26:25 -0500 Original-Received: from [61.8.2.231] (helo=mailout2.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GtuXQ-0003BK-Kf for guile-devel@gnu.org; Mon, 11 Dec 2006 18:26:25 -0500 Original-Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.2.163]) by mailout2.pacific.net.au (Postfix) with ESMTP id 811C610D260; Tue, 12 Dec 2006 10:26:18 +1100 (EST) Original-Received: from localhost (ppp271C.dyn.pacific.net.au [61.8.39.28]) by mailproxy2.pacific.net.au (Postfix) with ESMTP id AB6C02743C; Tue, 12 Dec 2006 10:26:18 +1100 (EST) Original-Received: from gg by localhost with local (Exim 4.63) (envelope-from ) id 1GtuXJ-0001g2-Vx; Tue, 12 Dec 2006 10:26:17 +1100 Original-To: ludo@chbouib.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Mail-Copies-To: never In-Reply-To: <877iwzokpz.fsf@chbouib.org> (Ludovic =?iso-8859-1?Q?Court=E8?= =?iso-8859-1?Q?s's?= message of "Sun, 10 Dec 2006 16:04:56 +0100") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:6310 Archived-At: ludo@chbouib.org (Ludovic Court=E8s) writes: > > In order to be consistent with the rest of `(ice-9 i18n)', > `language-information' accepts an optional argument which should be a > locale object. Consequently, `language-information' has to perform > appropriate charset conversion. If you ask for something from a particular locale object, shouldn't you get the charset of that object? That'd be what I'd expect. (Just for the time being of course, while encodings in strings are exposed.) > +# iconv.h - SuS v2 > +# iconv - X/Open, SuS v2 AM_ICONV (from gettext, see its manual) is good for that detection, it can cope with various oddities. > +@example > +(language-information DAY_1 (make-locale LC_ALL_MASK "C")) > +@result{} "Sunday" DAY_1 smells a lot like C, surely something more schemely is possible? After all, guile isn't a C interpreter with parenthesized syntax! :-) You should setup to use localeconv and strftime too, if nl_langinfo isn't available, that'd cope with DOS systems. Or if you want to tie only to nl_langinfo then calling the function nl-langinfo will make it clearest what's being had. > + scm_error (scm_system_error_key, func_name, > + "Failed to install locale", > + scm_cons (scm_strerror (s_err), SCM_EOL), > + scm_cons (s_err, SCM_EOL)); SCM_SYSERROR ? > + c_result =3D strdup (c_result); > + if (c_result =3D=3D NULL) > + { > + result =3D SCM_BOOL_F; > + /* FIXME: Raise an error. */ The frames stuff is the easiest way to cope with errors like out of memory from within a mutex lock. Though I suspect there's quite a few places in existing code that may leak resources of one type or another under out of memory errors. And I doubt out of memory is even recoverable at all if genuinely almost full. > +#define SCM_DEFINE_LOCALE_CATEGORY(_name) \ > + scm_c_define ("LC_" SCM_I18N_STRINGIFY (_name) "_MASK", \ > SCM_I_MAKINUM (LC_ ## _name ## _MASK)); scm_from_int (or long, as the case may be) can protect against the unlikely case of a mask bit outside the size of a fixnum. > + nconv =3D iconv (cc, (char **)&str, &len, > + &output, &output_avail); Incidentally, if you're thinking about iconv (which I suspect is not needed yet), then I've found it useful to also have conversions that put in dummies for untranslatable chars. With glibc the charset names "foo//TRANSLIT" etc give that effect, but elsewhere you have to watch for EILSEQ and skip that char. Good for output to at least display something. > (define priv:locale-abbr-weekday-vector > - (vector "Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat")) > + (cond-feature (language-information > + (vector ABDAY_1 ABDAY_2 ABDAY_3 > + ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7)) This raises a point about the interface. It should be possible to ask for "day number N". If ABDAY and friends aren't consecutive then they should be. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel