source: trunk/third/xml-i18n-tools/xml-i18n-unicodify @ 15545

Revision 15545, 1.6 KB checked in by ghudson, 24 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r15544, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#!/usr/bin/perl -w
2       
3#
4#  The i18n Unicode Encoding Utility
5#
6#  Copyright (C) 2001 Free Software Foundation.
7#
8#  This library is free software; you can redistribute it and/or
9#  modify it under the terms of the GNU General Public License as
10#  published by the Free Software Foundation; either version 2 of the
11#  License, or (at your option) any later version.
12#
13#  This script is distributed in the hope that it will be useful,
14#  but WITHOUT ANY WARRANTY; without even the implied warranty of
15#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16#  General Public License for more details.
17#
18#  You should have received a copy of the GNU General Public License
19#  along with this library; if not, write to the Free Software
20#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21#
22#  Authors:  Kenneth Christiansen <kenneth@gnu.org>
23#
24
25my $LANG = $ARGV[0];
26my $VERBOSE="1";
27
28if (! $LANG) {
29   print "You must specify the language\n";
30}
31
32open IN, "$LANG.po";
33
34while (<IN>) {
35    ## example: "Content-Type: text/plain; charset=ISO-8859-1\n"
36    if (/Content-Type\:.*charset=(.*)\\n/) {
37        $encoding_code_orig = $1;
38        last;
39    }
40}
41
42close IN;
43
44print "Converting from $encoding_code_orig\n" if $VERBOSE;
45
46my $extern_conv="iconv --from=$encoding_code_orig "
47               ."--to=UTF-8 $LANG.po > $LANG.po-1";
48
49system($extern_conv);
50
51my $source_orig;
52{
53    local (*IN);
54    local $/; #slurp mode
55    open (IN, "<$LANG.po-1") || die "can't open $LANG.po-1: $!";
56    $source_orig = <IN>;
57}
58
59$source_orig =~ s/Content-Type\:(.*)$encoding_code_orig/Content-Type\:$1UTF-8/;
60
61close IN;
62
63open OUT, ">$LANG.po-1";
64print OUT $source_orig;
65close OUT;
Note: See TracBrowser for help on using the repository browser.