Subject: Re: [PATCH] t9129: fix UTF-8 locale detection

From: Michael J Gruber <[email-masked]>
Date: Tue, 18 May 2010 18:05:16 +0200

Yann Droneaud venit, vidit, dixit 18.05.2010 16:41:
> Since I don't have en_US.utf8, some tests failed:
> 
>   * UTF-8 locale not available, test skipped
>   * skip 10: ISO-8859-1 should match UTF-8 in svn
>   * skip 11: eucJP should match UTF-8 in svn
>   * skip 12: ISO-2022-JP should match UTF-8 in svn
> 
> On my system locale -a reports:
> 
>    en_US
>    en_US.ISO-8859-1
>    en_US.UTF-8
> 

locale -a|grep en_US
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8

This is on Fedora 13, which is not exactly exotic. What is your system?

> According to Wikipedia utf8 is not a correct name
> for the UTF-8 encoding:
> http://en.wikipedia.org/wiki/UTF-8#Official_name_and_incorrect_variants
> 
> And compare_svn_head_with() is explicitly using en_US.UTF-8
> locale.
> 
> Signed-off-by: Yann Droneaud <[email-masked]>
> ---
>  t/t9129-git-svn-i18n-commitencoding.sh |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/t/t9129-git-svn-i18n-commitencoding.sh b/t/t9129-git-svn-i18n-commitencoding.sh
> index b9224bd..ec6ed4f 100755
> --- a/t/t9129-git-svn-i18n-commitencoding.sh
> +++ b/t/t9129-git-svn-i18n-commitencoding.sh
> @@ -69,7 +69,7 @@ do
>  	'
>  done
>  
> -if locale -a |grep -q en_US.utf8; then
> +if locale -a |grep -q en_US.UTF-8; then
>  	test_set_prereq UTF8
>  else
>  	say "UTF-8 locale not available, test skipped"

Funny thing is the test succeeds for me, even when run within
LANG=en_US.iso88591.
So I'd suggest to use

-if locale -a |grep -q en_US.utf8; then
+if locale -a |egrep -q 'en_US.utf8|en_US.UTF-8'; then

and embrace for more variants to appear down the road...

Michael