[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: More i18n
From: |
Kevin Ryde |
Subject: |
Re: More i18n |
Date: |
Tue, 12 Dec 2006 10:26:17 +1100 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
address@hidden (Ludovic Courtès) 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.
> address@hidden
> +(language-information DAY_1 (make-locale LC_ALL_MASK "C"))
> address@hidden "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 = strdup (c_result);
> + if (c_result == NULL)
> + {
> + result = 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 = 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.