> It will be nice if people from corresponding language start testing locale
> file and report bug to glibc.
> 
> It will help to correct glibc locale data.
> 
> Best Regards,
> ------------------
> Pravin Satpute


Thanks Pravin,

I have such utilities, written by Denis Barbier, that are sitting in
my ~/bin directory for a while. Let me share them here.

uxx2utf does the same job that the utility proposed by Parvin
utf2uxx does the opposite job and may be very useful for seding
patched versions.

If native speakers want to propose fixes for "their" locale, I suggest
sending them as patches to the original file, more than resending the
entire file.

#! /usr/bin/perl

use encoding 'utf8';

sub c {
        my $text = shift;
        my $ret = '';
        my $lastpos = 0;
        while ($text =~ m/\G(.*?)<U(....)>/g) {
                $lastpos = pos($text);
                $ret .= $1;
                my $n = hex($2);
                if ($n < 0x80) {
                        $ret .= pack("U", $n);
                } elsif ($n < 0xc0) {
                        $ret .= pack("UU", 0xc2, $n);
                } elsif ($n < 0x100) {
                        $ret .= pack("UU", 0xc3, $n & 0xbf);
                } else {
                        $ret .= pack("U", $n);
                }
        }
        return $ret.substr($text, $lastpos);
}

my $last = '';
while (<>) {
        if ($last ne '') {
                $_ = $last . $_;
                $last = '';
        }
        if (m/\/\s*$/s) {
                s/\/\s*$//s;
                $last = $_;
                next;
        }
        s/"([^"]*)"/'"'.c($1).'"'/eg;
        s/";\s*"/";"/g;
        print;
}

#! /usr/bin/perl -C1

sub c {
        my $text = shift;
        my $convert_ascii = shift;
        my $ret = '';
        while ($text =~ s/(.)//) {
                $l = unpack("U", $1);
                if ($convert_ascii == 0 && $l < 0x80) {
                        $ret .= $1;
                } else {
                        $ret .= sprintf "<U%04X>", $l;
                }
        }
        return $ret;
}

my $convert_ascii = 1;
while (<>) {
        if (/^LC_IDENTIFICATION/) {
                $convert_ascii = 0;
        } elsif (/^END LC_IDENTIFICATION/) {
                $convert_ascii = 1;
        }
        my $conv = $convert_ascii;
        $conv = 0 if (/^(copy|include)/);
        s/"([^"]*)"/'"'.c($1, $conv).'"'/eg;
        print;
}

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
IndLinux-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/indlinux-group

Reply via email to