Tcl Source Code

Artifact [4944d24b56]
Login

Artifact 4944d24b563b9560f63def4cca26694ae66852dc:

Attachment "eucjis.tcl" to ticket [526524ffff] added by furukawa 2002-03-07 01:24:46.
#!/usr/new/bin/tclsh8.1
# eucjis
# Kazuro FURUKAWA <[email protected]>, apr.24.1999. 
#
# this script tests character-set conversions mentioned 
# in the  message from scott stanton

set usage "eucjis (-eucjjis|-jiseuc) (-read|-gets) {input-file} {output-file}"

foreach {eucjis read input output} $argv {}
if {$output == ""} { puts stderr $usage ; exit 1 }
set infile [open $input r]
set outfile [open $output w]
switch -- $eucjis {
    -eucjis {
	fconfigure $infile -encoding euc-jp
	fconfigure $outfile -encoding iso2022-jp
    } -jiseuc {
	fconfigure $infile -encoding iso2022-jp
	fconfigure $outfile -encoding euc-jp
    } default { puts stderr $usage ; exit 1 }
}
switch -- $read {
    -read {
	puts -nonewline $outfile [read $infile]
    } -gets {
	while {[gets $infile line] != -1} {
	    puts $outfile $line
	}
    } default { puts stderr $usage ; exit 1 }
}
close $infile ; close $outfile