source: trunk/gsdl/bin/script/toutf8.pl@ 630

Last change on this file since 630 was 630, checked in by rjmcnab, 25 years ago

initial revision

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1#!/usr/local/bin/perl5 -w
2
3###########################################################################
4#
5# toutf8.pl -- converts to utf8
6#
7# Copyright (C) 1999 DigiLib Systems Limited, NZ.
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22#
23###########################################################################
24
25BEGIN {
26 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
27 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
28}
29
30use unicode;
31use multiread;
32use parsargv;
33
34
35$encoding = "utf8";
36if (!parsargv::parse(\@ARGV,
37 'unicode', \$unicode,
38 'extended', \$extended,
39 'gb', \$gb)) {
40 print STDERR "\n usage: $0 [options]\n\n";
41 print STDERR " options:\n";
42 print STDERR " -utf8 input is in utf-8 or unicode (default)\n";
43 print STDERR " -extended input is in extended ascii\n";
44 print STDERR " -gb input is in GB or GBK\n\n";
45 die "\n";
46}
47
48$encoding = "utf8" if $unicode;
49$encoding = "extended" if $extended;
50$encoding = "gb" if $gb;
51
52$reader = new multiread ();
53$reader->set_handle ('main::STDIN');
54$reader->set_encoding ($encoding);
55$line = "";
56while (defined ($line = $reader->read_line())) {
57 print $line;
58}
Note: See TracBrowser for help on using the repository browser.