From: <arj...@us...> - 2011-01-11 08:22:55
|
Revision: 11477 http://plplot.svn.sourceforge.net/plplot/?rev=11477&view=rev Author: arjenmarkus Date: 2011-01-11 08:22:48 +0000 (Tue, 11 Jan 2011) Log Message: ----------- Add the workaround for Tcl 8.4 (wrt encoding issues on Windows) to the overall demonstration programs. Modified Paths: -------------- trunk/examples/tcl/tcldemos.tcl trunk/examples/tk/tkdemos.tcl Modified: trunk/examples/tcl/tcldemos.tcl =================================================================== --- trunk/examples/tcl/tcldemos.tcl 2011-01-11 07:57:04 UTC (rev 11476) +++ trunk/examples/tcl/tcldemos.tcl 2011-01-11 08:22:48 UTC (rev 11477) @@ -17,9 +17,45 @@ # Tcl scripts compatible. #---------------------------------------------------------------------------- +proc sourceUtf8 {sourceFile} { + + if { [encoding system] != "utf-8" } { + if { [package vsatisfies [info patch] 8.5] } { + + source -encoding utf-8 $sourceFile + + } else { + + # + # Pre-Tcl 8.5 + # + set infile [open $sourceFile] + set contents [read $infile] + close $infile + eval [encoding convertfrom utf-8 \ + [encoding convertto [encoding system] $contents]] + } + } else { + source $sourceFile + } +} + +set utf8_examples {4 18 24 26 33} + for {set i 1} {$i <= 31} {incr i} { set demo x[format "%02d" $i] - source $demo.tcl + + # + # If the source code contains UTF-8 characters (beyond the + # ASCII-7 encoding), take special measures + # + + if { [lsearch $utf8_examples $i] < 0 } { + source $demo.tcl + } else { + sourceUtf8 $demo.tcl + } + # restore defaults proc $i {} " $demo Modified: trunk/examples/tk/tkdemos.tcl =================================================================== --- trunk/examples/tk/tkdemos.tcl 2011-01-11 07:57:04 UTC (rev 11476) +++ trunk/examples/tk/tkdemos.tcl 2011-01-11 08:22:48 UTC (rev 11477) @@ -17,13 +17,49 @@ # Tcl scripts compatible. #---------------------------------------------------------------------------- +proc sourceUtf8 {sourceFile} { + + if { [encoding system] != "utf-8" } { + if { [package vsatisfies [info patch] 8.5] } { + + source -encoding utf-8 $sourceFile + + } else { + + # + # Pre-Tcl 8.5 + # + set infile [open $sourceFile] + set contents [read $infile] + close $infile + eval [encoding convertfrom utf-8 \ + [encoding convertto [encoding system] $contents]] + } + } else { + source $sourceFile + } +} + +set utf8_examples {4 18 24 26 33} + plstdwin . plxframe .plw pack append . .plw {left expand fill} for {set i 1} {$i <= 31} {incr i} { set demo x[format "%02d" $i] - source $demo.tcl + + # + # If the source code contains UTF-8 characters (beyond the + # ASCII-7 encoding), take special measures + # + + if { [lsearch $utf8_examples $i] < 0 } { + source $demo.tcl + } else { + sourceUtf8 $demo.tcl + } + proc $i {} " .plw.plwin cmd plspause 0 $demo .plw.plwin This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |