unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Eli Zaretskii <eliz@gnu.org>
Cc: guile-devel@gnu.org
Subject: Re: MinGW vs. setlocale
Date: Thu, 12 Jun 2014 10:39:08 +0200	[thread overview]
Message-ID: <87oaxyjzdf.fsf@gnu.org> (raw)
In-Reply-To: <83fvjbzcjd.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 11 Jun 2014 18:33:26 +0300")

Eli Zaretskii <eliz@gnu.org> skribis:

>> From: ludo@gnu.org (Ludovic Courtès)
>> Cc: guile-devel@gnu.org
>> Date: Wed, 11 Jun 2014 15:13:58 +0200

[...]

>> > After all these changes, some tests still fail or throw exceptions:
>> >
>> >   UNRESOLVED: i18n.test: text collation (French): string-locale-ci=?
>> >   UNRESOLVED: i18n.test: text collation (French): string-locale-ci=? (2 args, wide strings)
>> >   UNRESOLVED: i18n.test: text collation (French): string-locale-ci=? (3 args, wide strings)
>> >   UNRESOLVED: i18n.test: text collation (French): string-locale-ci<>?
>> >   UNRESOLVED: i18n.test: text collation (French): string-locale-ci<>? (wide strings)
>> >   UNRESOLVED: i18n.test: text collation (French): string-locale-ci<>? (wide and narrow strings)
>> >   UNRESOLVED: i18n.test: text collation (French): char-locale-ci<>?
>> >   UNRESOLVED: i18n.test: text collation (French): char-locale-ci<>? (wide)
>> >   UNRESOLVED: i18n.test: text collation (Greek): string-locale-ci=?
>> >   UNRESOLVED: i18n.test: character mapping: char-locale-upcase Turkish
>> >   UNRESOLVED: i18n.test: character mapping: char-locale-downcase Turkish
>> >   UNRESOLVED: i18n.test: string mapping: string-locale-upcase Greek
>> >   UNRESOLVED: i18n.test: string mapping: string-locale-upcase Greek (two sigmas)
>> >   UNRESOLVED: i18n.test: string mapping: string-locale-downcase Greek
>> >   UNRESOLVED: i18n.test: string mapping: string-locale-downcase Greek (two sigmas)
>> >   UNRESOLVED: i18n.test: string mapping: string-locale-upcase Turkish
>> >   UNRESOLVED: i18n.test: string mapping: string-locale-downcase Turkish
>> >
>> > I don't know why these fail.
>> 
>> Note that “UNRESOLVED” is not a failure; it means “we can’t run this
>> test here, so skip it.”
>
> Yes, I understand that.  But "can't run" usually means the test threw
> some kind of exception, and I didn't understand why, especially since
> _some_ of the text collation tests did work (compare the above with
> the full list).
>
> I now know what is the reason for that, and I cannot say that I'm
> happier: it's libunistring's fault.  All these tests call libunistring
> functions that require the locale's language as an argument.  Problem
> is, libunistring doesn't support languages such as "fra" or "trk", it
> only supports "fr" and "tr".  In general, it only supports 3-letter
> language codes for those languages for which a 2-letter code doesn't
> exist.  By contrast, Windows _always_ uses 3-letter codes in valid
> locale names.
>
> So what happens is that locale_language always returns an empty
> string, and Guile calls u32_casecoll etc. with that empty string,
> which only works in the "C" locale.  In any other locale, the
> comparison fails with EILSEQ, and Guile throws the appropriate
> exception.

OK.  (It would be nice if someone would take over maintainership of
libunistring...)

> IOW, libunistring's port to Windows is not really useful.
>
> I will have to find some way around this issue, because otherwise
> Guile will be crippled in any locale but en_US.
>
> (Btw, why does Guile use libunistring instead of the ANSI functions
> for locale-dependent string comparison and collation?)

Because strings are internally either Latin-1 or UTF-32 (UCS-4).

[...]

>> >   FAIL: i18n.test: number->locale-string: French: integer
>> >   FAIL: i18n.test: number->locale-string: French: fraction
>> >   FAIL: i18n.test: number->locale-string: French: fraction, 1 digit
>> >   FAIL: i18n.test: monetary-amount->locale-string: French: integer
>> >   FAIL: i18n.test: monetary-amount->locale-string: French: fraction
>> >
>> > There's no blank after the 7th digit, where the test expects it.  Not
>> > sure what kind of problem is that, perhaps again due to gnulib's
>> > nl_langinfo.
>> 
>> You could try this:
>> 
>> --8<---------------cut here---------------start------------->8---
>> scheme@(guile-user)> ,m (ice-9 i18n)
>> scheme@(ice-9 i18n)> (locale-decimal-point (make-locale LC_ALL "fr_FR"))
>> $2 = ","
>> scheme@(ice-9 i18n)> (locale-thousands-separator (make-locale LC_ALL "fr_FR"))
>> $3 = " "
>> --8<---------------cut here---------------end--------------->8---
>
> I did try that, and saw a strange thing: the thousands separator is
> displayed as "\xa0".  That is very strange, because nl_langinfo does
> return " " for the French locale, as expected.  Why would the blank be
> translated into NBSP?  Can this also be due to libunistring problems?

NBSP is actually a better answer than just space, because it’d be unwise
to introduce a break in the middle of a number.

So does ‘number->locale-string’ return "123\xa0456" for you?

>> (Using the right locale name.)
>> 
>> >   UNRESOLVED: i18n.test: format ~h: French: 12345.5678
>> >   UNRESOLVED: i18n.test: format ~h: English: 12345.5678
>> >
>> > ~h is not supported on Windows.
>> 
>> ~h is implemented using ‘number->locale-string’.
>
> Maybe I'm confused, but isn't ~h about position directive in formats?

Yes, but that’s implemented in Scheme, in ice-9/format.scm.

> These don't work on Windows.

What doesn’t work?  ‘format’ doesn’t rely on any non-portable OS
facility.

Thanks,
Ludo’.



  reply	other threads:[~2014-06-12  8:39 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-08 15:04 MinGW issues in Guile 2.0.11 Eli Zaretskii
2014-06-09 15:47 ` Eli Zaretskii
2014-06-09 18:01 ` Mark H Weaver
2014-06-09 18:25   ` Eli Zaretskii
2014-06-09 19:30 ` MinGW vs. setlocale Ludovic Courtès
2014-06-10 16:17   ` Eli Zaretskii
2014-06-11 13:13     ` Ludovic Courtès
2014-06-11 15:33       ` Eli Zaretskii
2014-06-12  8:39         ` Ludovic Courtès [this message]
2014-06-12 18:18           ` Eli Zaretskii
2014-06-15 17:23             ` Eli Zaretskii
2014-06-21 11:17               ` Eli Zaretskii
2014-06-21 15:02               ` Ludovic Courtès
2014-06-21 15:11                 ` Eli Zaretskii
2014-06-21 21:23                   ` Ludovic Courtès
2014-06-22 16:13                     ` Eli Zaretskii
2014-06-19  4:53       ` Doug Evans
2014-06-19  8:16         ` Ludovic Courtès
2014-06-09 19:32 ` MinGW vs. c-api.test Ludovic Courtès
2014-06-10  9:05   ` Neil Jerram
2014-06-10 11:42     ` Ludovic Courtès
2014-06-10 15:32     ` Eli Zaretskii
2014-06-10 15:56       ` David Kastrup
2014-06-10 18:00         ` Eli Zaretskii
2014-06-11  0:36           ` dsmich
2014-06-11  2:52             ` Eli Zaretskii
2014-06-10 11:44   ` Ludovic Courtès
2014-06-10 15:39     ` Eli Zaretskii
2014-06-11 12:37       ` Ludovic Courtès
2014-06-11 15:08         ` Eli Zaretskii
2014-06-12  8:29           ` Ludovic Courtès
2014-06-12 17:16             ` Eli Zaretskii
2014-06-12 19:48               ` Ludovic Courtès
2014-06-12 19:59                 ` Eli Zaretskii
2014-06-12 21:20                   ` Ludovic Courtès
2014-06-13  9:15                     ` Neil Jerram
2014-06-13 16:04                       ` Ludovic Courtès
2014-06-13 16:19                         ` Eli Zaretskii
2014-06-13 16:26                           ` Neil Jerram
2014-06-13 16:31                         ` Mike Gerwitz
2014-06-13 18:09                           ` Eli Zaretskii
2014-06-09 19:42 ` Windows file name separators Ludovic Courtès
2014-06-10 16:00   ` Eli Zaretskii
2014-06-30 11:15     ` Ludovic Courtès
2014-06-30 14:56       ` Eli Zaretskii
2014-07-01  9:36         ` Ludovic Courtès
2014-07-01 15:30           ` Eli Zaretskii
2014-07-01 15:38             ` Ludovic Courtès
2014-07-02 16:04               ` Eli Zaretskii
2014-07-02 20:56                 ` Ludovic Courtès
2014-07-02 20:57                 ` Ludovic Courtès
2014-07-03 15:10                   ` Eli Zaretskii
2014-07-03 17:11                     ` Ludovic Courtès
2014-07-03 18:09                       ` Eli Zaretskii
2014-07-07 20:53                         ` Mark H Weaver
2014-07-08  2:37                           ` Eli Zaretskii
2014-07-02 16:13               ` Fix 'dirname' and 'basename' on MS-Windows Eli Zaretskii
2014-07-09 14:22                 ` Ludovic Courtès
2014-07-09 14:53                   ` Eli Zaretskii
2014-07-02 16:16               ` Provide reasonable stack limit " Eli Zaretskii
2014-07-02 21:02                 ` Ludovic Courtès
2014-07-03 16:28                   ` Eli Zaretskii
2014-07-02 16:30               ` Bug in scm_getaffinity Eli Zaretskii
2014-07-02 21:04                 ` Ludovic Courtès
2014-07-03 16:31                   ` Eli Zaretskii

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=87oaxyjzdf.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=eliz@gnu.org \
    --cc=guile-devel@gnu.org \
    /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).