#!/usr/local/bin/perl

use Getopt::Std;
use Jcode;

$target_code = "euc";

main( );
exit( 0 );

sub usage(){
    printf( "nkf.pl [switch] < in > out \n" );
    printf( " switch : -j ... jis  \n" );
    printf( "          -s ... sjis \n" );
    printf( "          -e ... euc  \n" );
    printf( "          -u ... utf8 \n" );
}

sub main (){
  getopts( 'jseuh' );
  if( $opt_h ) {
      usage( );
      exit( 0 );
  }

  @list = <>;
  $str = join( "", @list );
  #printf( "length = %d\n", length( $str ));

  if( $opt_j ) { $target_code = "jis"; }
  if( $opt_s ) { $target_code = "sjis"; }
  if( $opt_e ) { $target_code = "euc"; }
  if( $opt_u ) { $target_code = "utf8"; }
  
  Jcode::convert( \$str, $target_code );
  print $str;
}
