[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#312927: glibc: Please use UTF-8 as the default locale codeset



GOTO Masanori <gotom@debian.or.jp> writes:

> At Tue, 19 Jul 2005 19:18:37 +0100,
> Roger Leigh wrote:
>> > I would like to put this version to locales package.  I welcome your
>> > comments and patches.
>> 
>> That sounds fine.  I can rework the patch for you.
>
> Thanks, I'm looking forward to your patch.

It's here (but untested, because the glibc build currently fails on my
system; perhaps I need the experimental glibc?):

diff -urN glibc-2.3.2.ds1.original/debian/debhelper.in/locales.templates glibc-2.3.2.ds1/debian/debhelper.in/locales.templates
--- glibc-2.3.2.ds1.original/debian/debhelper.in/locales.templates	2005-07-20 17:56:10.000000000 +0100
+++ glibc-2.3.2.ds1/debian/debhelper.in/locales.templates	2005-07-20 19:06:01.908606928 +0100
@@ -8,6 +8,11 @@
  Choose which locales to generate.  The selection will be saved to
  `/etc/locale.gen', which you can also edit manually (you need to run
  `locale-gen' afterwards).
+ .
+ UTF-8 locales should be chosen by default.  If you are a performing a
+ new installation, or are unsure which character set to use, UTF-8 is
+ usually the best choice.  Other character sets are useful for
+ backwards compatibility with older systems and software.
 
 Template: locales/default_environment_locale
 Type: select
diff -urN glibc-2.3.2.ds1.original/debian/rules.d/debhelper.mk glibc-2.3.2.ds1/debian/rules.d/debhelper.mk
--- glibc-2.3.2.ds1.original/debian/rules.d/debhelper.mk	2005-07-20 17:56:10.000000000 +0100
+++ glibc-2.3.2.ds1/debian/rules.d/debhelper.mk	2005-07-20 19:08:19.229730944 +0100
@@ -225,7 +225,7 @@
 	done
 
 	# Substitute __SUPPORTED_LOCALES__.
-	perl -i -pe 'BEGIN {undef $$/; open(IN, "debian/tmp-libc/usr/share/i18n/SUPPORTED"); $$j=<IN>;} s/__SUPPORTED_LOCALES__/$$j/g;' debian/locales.config
+	perl -i -pe 'BEGIN { open(IN, "debian/tmp-libc/usr/share/i18n/SUPPORTED"); $$out = $$cblock = ""; $$oldloc = $$curloc = ""; $$utf8loc = 0; while (<IN>) { chomp $$_; if (/^([a-z]+_[A-Z]+).*$$/) { $$curloc = $$1; } if ($$oldloc eq "") { $$oldloc = $$curloc; } if ($$curloc ne $$oldloc) { if ($$utf8loc == 0) { printf STDERR "$$curloc: No UTF-8 locale\n"; } $$utf8loc = 0; $$out .= $$cblock; $$cblock = ""; $$oldloc = $$curloc; } if (/UTF\-8/) { $$out .= "$$_\n"; $$utf8loc = 1; } else { $$cblock .= "$$_\n"; } } $$out .= $$cblock; } s/__SUPPORTED_LOCALES__/$$out/g;' debian/locales.config
 
 	# Generate common substvars files.
 	echo "locale:Depends=$(shell perl debian/debver2localesdep.pl $(DEB_VERSION))" > tmp.substvars


Because the perl script is a bit larger, I wrote it as a proper
script.  It might be better as a separate file, for ease of
maintenance.

BEGIN {
    open(IN, "debian/tmp-libc/usr/share/i18n/SUPPORTED");
    $out = $cblock = "";
    $oldloc = $curloc = "";
    $utf8loc = 0;
    while (<IN>) {
	chomp $_;

	if (/^([a-z]+_[A-Z]+).*$/) {
	    $curloc = $1;
	}
	if ($oldloc eq "") {
	    $oldloc = $curloc;
	}

	if ($curloc ne $oldloc) {
	    if ($utf8loc == 0) {
		printf STDERR "$curloc: No UTF-8 locale\n";
	    }
	    $utf8loc = 0;

	    $out .= $cblock;
	    $cblock = "";
	    $oldloc = $curloc;
	}

	if (/UTF\-8/) {
	    $out .= "$_\n";
	    $utf8loc = 1;
	} else {
	    $cblock .= "$_\n";
	}
    }
    $out .= $cblock;
}

s/__SUPPORTED_LOCALES__/$out/g;


Regards,
Roger

-- 
Roger Leigh
                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                Debian GNU/Linux        http://www.debian.org/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.



Reply to: