nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] hardcoding en_US.UTF-8 in test cases

2013-02-07 20:10:50
Ken Hornstein wrote:
Huh, okay ... forgive my US-centricism, but at least on every system
here we have tons of locales installed so I figured that was the case
everywhere, and I picked something I figured was pretty universal.  May

It probably depends on how the system was installed, with some installers
including a full set regardless. Minimal sets of locales appears to be
fairly prevalent on systems I have access to.

May
I ask how come you have a Finnish locale but not a US one?  This isn't
some harsh feelings left over from the War of 1812, is it? :-)

:-) The Finnish locale is there for my wife. 
I've probably got harsher feelings for your mixed up month day year date
formats. Though, the C locale probably specifies that too.
 
FWIW, none of the systems I have access to (even the Linux ones) have a
C.UTF-8 locale.  It's not clear to me how standardized those locale names
are.

I only see it on my recent Debian box. Like C, it can't be removed with
dpkg-reconfigure -p low locales.

        [language[_territory][.codeset][@modifier]

Not sure if that helps anything or not.  On some systems I see a locale
just called "UTF-8", but that seems to be rare.

I've not seen "UTF-8" anywhere. @euro is the only modifier I've seen but it
still seems to be common.

I've attempted a script for finding a locale (see below). It will prefer
C.UTF-8 or plain UTF-8  but not en_xx as that complicates the script
quite a bit.

To use it, you would do:
eval `./findutf8locale` || skip test

Oliver

#!/bin/sh
##
# findutf8locale - A script that attempts to find a suitable locale for use
#                  with tests that require UTF-8 support
##

# if Nmh has no multibyte support, fail
./getcwidth a >/dev/null 2>&1 || exit 1
# if the current locale does the job, use it
[ "`./getcwidth ä 2>&1`" = 1 ] && exit 0

if LOCALE=`command -v locale 2>/dev/null`; then
  LOCALE="$LOCALE -a | sed 's/utf8/UTF-8/'"
elif [ -d /usr/lib/locale ]; then
  LOCALE="ls -1 /usr/lib/locale"
else
  exit 1
fi

$LOCALE | grep UTF-8 | LC_COLLATE=C sort | uniq | while read line; do
  if [ "`LC_CTYPE="$line" ./getcwidth ä 2>&1`" = 1 ]; then
    echo LC_CTYPE="$line"
    exit
  fi
done

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers
<Prev in Thread] Current Thread [Next in Thread>