From: <arj...@us...> - 2011-01-07 07:46:51
|
Revision: 11447 http://plplot.svn.sourceforge.net/plplot/?rev=11447&view=rev Author: arjenmarkus Date: 2011-01-07 07:46:45 +0000 (Fri, 07 Jan 2011) Log Message: ----------- Solve the encoding issue for examples 18, 24 and 26 (example 33 is still to be implemented). The solution was suggested by several people on the comp.lang.tcl newsgroup. From Tcl 8.5 onwards we can use the -encoding option to the source command, for earlier versions we explicitly convert the contents of the file to UTF-8 before eval'ing it. Modified Paths: -------------- trunk/examples/tcl/x18 trunk/examples/tcl/x24 trunk/examples/tcl/x26 Modified: trunk/examples/tcl/x18 =================================================================== --- trunk/examples/tcl/x18 2011-01-06 13:39:37 UTC (rev 11446) +++ trunk/examples/tcl/x18 2011-01-07 07:46:45 UTC (rev 11447) @@ -12,8 +12,33 @@ #\ exec pltcl -f "$0" ${1+"$@"} -source x18.tcl +# +# This example uses UTF-8 characters, placed directly in the source code +# +if { [encoding system] != "utf-8" } { + if { [package vsatisfies [info patch] 8.5] } { + source -encoding utf-8 x18.tcl + + } else { + + # + # Pre-Tcl 8.5 + # + set infile [open "x18.tcl"] + set contents [read $infile] + close $infile + eval [encoding convertfrom utf-8 \ + [encoding convertto [encoding system] $contents]] + } +} else { + + # + # Plain source will do + # + source x18.tcl +} + plinit x18 plend Modified: trunk/examples/tcl/x24 =================================================================== --- trunk/examples/tcl/x24 2011-01-06 13:39:37 UTC (rev 11446) +++ trunk/examples/tcl/x24 2011-01-07 07:46:45 UTC (rev 11447) @@ -1,6 +1,6 @@ #!/bin/sh #--------------------------------*- Tcl -*------------------------------------# -# $Id:$ +# $Id$ # # Maurice LeBrun # 12/24/02 @@ -12,8 +12,33 @@ #\ exec pltcl -f "$0" ${1+"$@"} -source x24.tcl +# +# This example uses UTF-8 characters, placed directly in the source code +# +if { [encoding system] != "utf-8" } { + if { [package vsatisfies [info patch] 8.5] } { + source -encoding utf-8 x24.tcl + + } else { + + # + # Pre-Tcl 8.5 + # + set infile [open "x24.tcl"] + set contents [read $infile] + close $infile + eval [encoding convertfrom utf-8 \ + [encoding convertto [encoding system] $contents]] + } +} else { + + # + # Plain source will do + # + source x24.tcl +} + plinit x24 plend Modified: trunk/examples/tcl/x26 =================================================================== --- trunk/examples/tcl/x26 2011-01-06 13:39:37 UTC (rev 11446) +++ trunk/examples/tcl/x26 2011-01-07 07:46:45 UTC (rev 11447) @@ -12,8 +12,33 @@ #\ exec pltcl -f "$0" ${1+"$@"} -source x26.tcl +# +# This example uses UTF-8 characters, placed directly in the source code +# +if { [encoding system] != "utf-8" } { + if { [package vsatisfies [info patch] 8.5] } { + source -encoding utf-8 x26.tcl + + } else { + + # + # Pre-Tcl 8.5 + # + set infile [open "x26.tcl"] + set contents [read $infile] + close $infile + eval [encoding convertfrom utf-8 \ + [encoding convertto [encoding system] $contents]] + } +} else { + + # + # Plain source will do + # + source x26.tcl +} + plinit x26 plend This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |