source: branches/New_Config_Format-branch/gsdl/bin/script/togb.pl@ 1279

Last change on this file since 1279 was 1279, checked in by sjboddie, 24 years ago

merged changes to trunk into New_Config_Format branch

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1#!/usr/bin/perl -w
2
3###########################################################################
4#
5# togb.pl -- converts to GB
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 'iso_8859_1', \$iso_8859_1,
39 'gb', \$gb)) {
40 print STDERR "\n usage: $0 [options]\n\n";
41 print STDERR " options:\n";
42 print STDERR " -unicode input is in utf-8 or unicode (default)\n";
43 print STDERR " -iso_8859_1 input is in extended ascii (ISO-8859-1 Latin 1)\n";
44 print STDERR " -gb input is in GB or GBK (simplified Chinese)\n\n";
45 die "\n";
46}
47
48$encoding = "utf8" if $unicode;
49$encoding = "iso_8859_1" if $iso_8859_1;
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 &gb::unicode2gb (&unicode::utf82unicode ($line));
58}
Note: See TracBrowser for help on using the repository browser.