After apply the attached patch, I can test the implementation. It work for me with CP950 and utf8 encoding and fit my need for editing utf8 files.<br><br>But I feel the encoding list is too long for  selecting. I think most users only play with a few of them but they distributed among this long encoding list  that make selection difficult.<br>
<br>Can we put the most recent selected encoding at the top of the list or just put system encoding and utf8 at the top ? <br><br><br>Yung-Jang Lee <br><br><br><div class="gmail_quote">2008/12/16 François Vogel <span dir="ltr"><<a href="mailto:fvogelnew1@free.fr">fvogelnew1@free.fr</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi all,<br>
<br>
Please find attached SEP #12 (V1.0) which describes the proposed changes in Scipad for supporting more encodings, as an answer to a recent request from Yung-Jang Lee.<br>
<br>
The SEP includes a full implementation, that I also attach to this email for your convenience (utf-8 encoded diff).<br>
<br>
Please comment as needed and give your opinion especially on the expressed limitations of the current proposal.<br>
<br>
Francois<br>
<br>--- tcl/msg_files/fr_fr.msg     Sat Dec 13 15:13:14 2008<br>
+++ tcl/msg_files/fr_fr.msg     Sun Dec 14 21:10:16 2008<br>
@@ -25,7 +25,7 @@<br>
 #<br>
<br>
 # Scipad texts in French by Francois Vogel<br>
-# in sync at least with v7.11<br>
+# in sync at least with v7.12<br>
<br>
<br>
 # commons<br>
@@ -640,6 +640,7 @@<br>
     ::msgcat::mcset fr_fr "Execution &errors" "E&rreurs d'exécution"<br>
         ::msgcat::mcset fr_fr "In Scilab &shell only" "Dans la fenêtre &Scilab seulement"<br>
         ::msgcat::mcset fr_fr "Copied in a &message box" "Recopiées dans une &boîte de dialogue"<br>
+    ::msgcat::mcset fr_fr "Enc&oding" "Encod&age"<br>
     ::msgcat::mcset fr_fr "E&xit options" "Option&s de fermeture"<br>
         ::msgcat::mcset fr_fr "Show closure &X" "Afficher le bouton &X de fermeture"<br>
         ::msgcat::mcset fr_fr "Exit on &last file close" "Quitte si &dernier fichier fermé"<br>
--- tcl/buffernavigation.tcl    Thu Nov 13 21:23:19 2008<br>
+++ tcl/buffernavigation.tcl    Sun Dec 14 21:36:56 2008<br>
@@ -358,6 +358,7 @@<br>
 # Set all the settings such that $textarea becomes the current one<br>
     global pad Scheme ColorizeIt listoffile textareaid<br>
     global buffermodifiedsincelastsearch<br>
+    global currentencoding<br>
<br>
     # clear the selection when leaving a buffer - check first that the<br>
     # textarea still exists because it might have been destroyed when<br>
@@ -376,6 +377,7 @@<br>
     keyposn $textarea<br>
     set Scheme $listoffile("$textarea",language)<br>
     set ColorizeIt $listoffile("$textarea",colorize)<br>
+    set currentencoding $listoffile("$textarea",encoding)<br>
     schememenus $textarea<br>
     highlighttextarea $textarea<br>
     TextStyles $textarea<br>
@@ -546,6 +548,7 @@<br>
 # it creates a new empty textarea<br>
     global winopened listoffile<br>
     global listoftextarea pad<br>
+    global defaultencoding<br>
<br>
     # ensure that the cursor is changed to the default cursor<br>
     event generate [gettextareacur] <Leave><br>
@@ -564,6 +567,7 @@<br>
     set listoffile("$pad.new$winopened",undostackdepth) 0<br>
     set listoffile("$pad.new$winopened",redostackdepth) 0<br>
     set listoffile("$pad.new$winopened",progressbar_id) ""<br>
+    set listoffile("$pad.new$winopened",encoding) $defaultencoding<br>
     lappend listoftextarea $pad.new$winopened<br>
<br>
     addwindowsmenuentry $winopened $listoffile("$pad.new$winopened",displayedname)<br>
@@ -617,6 +621,7 @@<br>
     set listoffile("$newta",undostackdepth) $listoffile("$ta",undostackdepth)<br>
     set listoffile("$newta",redostackdepth) $listoffile("$ta",redostackdepth)<br>
     set listoffile("$newta",progressbar_id) $listoffile("$ta",progressbar_id)<br>
+    set listoffile("$newta",encoding) $listoffile("$ta",encoding)<br>
     lappend listoftextarea $newta<br>
<br>
     addwindowsmenuentry $winopened $listoffile("$pad.new$winopened",displayedname)<br>
--- tcl/defaults.tcl    Sat Dec 13 15:13:14 2008<br>
+++ tcl/defaults.tcl    Sun Dec 14 21:57:31 2008<br>
@@ -296,6 +296,10 @@<br>
 # frame pathname in which $textarea is packed, or "none" if it is not packed<br>
 array unset pwframe<br>
<br>
+# default encoding is the system native encoding<br>
+set defaultencoding [encoding system]<br>
+set currentencoding $defaultencoding<br>
+<br>
 #############<br>
 # source the user preferences file if any<br>
 # this must happen after the locale selection from Scilab's getlanguage() above<br>
--- tcl/filecommands.tcl        Sat Dec 13 15:13:14 2008<br>
+++ tcl/filecommands.tcl        Sun Dec 14 23:04:27 2008<br>
@@ -111,6 +111,10 @@<br>
 #       true: file gets colorized<br>
 #       false: no colorization for this file<br>
 #<br>
+#     listoffile("$ta",encoding)<br>
+#       name of the encoding in which the file is stored,<br>
+#       e.g. utf-8 or euc-jp or cp1252 or a lot of other possibilities<br>
+#<br>
 #   The windows menu entries are radionbuttons, with the following<br>
 #   properties:<br>
 #     -value is $winopened<br>
@@ -135,6 +139,7 @@<br>
 proc filesetasnew {} {<br>
     global winopened listoffile<br>
     global listoftextarea pad<br>
+    global defaultencoding<br>
<br>
     # ensure that the cursor is changed to the default cursor<br>
     event generate [gettextareacur] <Leave><br>
@@ -151,6 +156,7 @@<br>
     set listoffile("$pad.new$winopened",undostackdepth) 0<br>
     set listoffile("$pad.new$winopened",redostackdepth) 0<br>
     set listoffile("$pad.new$winopened",progressbar_id) ""<br>
+    set listoffile("$pad.new$winopened",encoding) $defaultencoding<br>
     lappend listoftextarea $pad.new$winopened<br>
<br>
     addwindowsmenuentry $winopened $listoffile("$pad.new$winopened",displayedname)<br>
@@ -341,6 +347,7 @@<br>
         unset listoffile("$textarea",undostackdepth)<br>
         unset listoffile("$textarea",redostackdepth)<br>
         unset listoffile("$textarea",progressbar_id)<br>
+        unset listoffile("$textarea",encoding)<br>
<br>
         # the rest of this proc is similar to proc hidetext,<br>
         # but not identical<br>
@@ -838,6 +845,8 @@<br>
 # $file is not opened - this sets the $listoffile area values for that file<br>
 # and adds an entry in the windows menu<br>
     global winopened pad listoffile<br>
+    global currentencoding<br>
+<br>
     incr winopened<br>
     dupWidgetOption [gettextareacur] $pad.new$winopened<br>
     set listoffile("$pad.new$winopened",fullname) [file normalize $file]<br>
@@ -854,6 +863,8 @@<br>
     set listoffile("$pad.new$winopened",undostackdepth) 0<br>
     set listoffile("$pad.new$winopened",redostackdepth) 0<br>
     set listoffile("$pad.new$winopened",progressbar_id) ""<br>
+    # there is no automatic detection of encoding (so far) <TODO>: do it at least for xml files<br>
+    set listoffile("$pad.new$winopened",encoding) $currentencoding<br>
<br>
     addwindowsmenuentry $winopened $listoffile("$pad.new$winopened",displayedname)<br>
 }<br>
@@ -899,6 +910,7 @@<br>
 # really open/read a file from disk<br>
 # all readability tests have normally been done before<br>
     global listoftextarea pad closeinitialbufferallowed<br>
+    global listoffile<br>
     set msgWait [mc "Wait seconds while loading and colorizing file"]<br>
     showinfo $msgWait<br>
     lappend listoftextarea $textarea<br>
@@ -907,6 +919,7 @@<br>
         closefile $pad.new1<br>
     }<br>
     set newnamefile [open $thefile r]<br>
+    fconfigure $newnamefile -encoding $listoffile("$textarea",encoding)<br>
     while {![eof $newnamefile]} {<br>
         $textarea insert end [read -nonewline $newnamefile ]<br>
     }<br>
@@ -1137,7 +1150,7 @@<br>
 # really write the file onto the disk<br>
 # all writability tests have normally been done before<br>
     global filebackupdepth tcl_platform<br>
-    global pad<br>
+    global pad listoffile<br>
<br>
     if {$nobackupskip} {<br>
         backupfile $nametosave $filebackupdepth<br>
@@ -1186,6 +1199,7 @@<br>
     }<br>
<br>
     set FileNameToSave [open $nametosave w]<br>
+    fconfigure $FileNameToSave -encoding $listoffile("$textarea",encoding)<br>
     puts -nonewline $FileNameToSave [$pad.temptextwidget get 1.0 end]<br>
     close $FileNameToSave<br>
<br>
@@ -1329,6 +1343,24 @@<br>
     foreach ta [filteroutpeers $listoftextarea] {<br>
         checkiffilechangedondisk $ta<br>
     }<br>
+}<br>
+<br>
+##################################################<br>
+# file encoding procs<br>
+##################################################<br>
+proc setencoding {} {<br>
+# set the encoding property of the current buffer to be the encoding<br>
+# currently selected in the encoding options menu<br>
+# this proc is called when selecting any option of this menu<br>
+    global currentencoding listoffile<br>
+    set textarea [gettextareacur]<br>
+    foreach ta [getfullpeerset $textarea] {<br>
+        set listoffile("$ta",encoding) $currentencoding<br>
+        modifiedtitle $ta<br>
+    }<br>
+    # this is mandatory because any system calls get mangled otherwise<br>
+    # such as passing a filename to the system<br>
+    encoding system $currentencoding<br>
 }<br>
<br>
 ##################################################<br>
--- tcl/infomessages.tcl        Sat Dec 13 15:13:14 2008<br>
+++ tcl/infomessages.tcl        Sun Dec 14 22:56:31 2008<br>
@@ -173,24 +173,30 @@<br>
<br>
 proc modifiedtitle {textarea {panesonly "false"}} {<br>
 # Set the Scipad window title to the name of the file displayed in $textarea<br>
-# and add tags (modified, readonly)<br>
+# and add tags (modified, readonly, encoding (if different from the system<br>
+# encoding at Scipad startup))<br>
 # Do the same for the pane title if it exists (i.e. if not maximized)<br>
 # Update also the visual indications of the modified state of the buffer.<br>
 # This includes title bar, colorization of the windows menu entry and<br>
 # colorization of an area in the status bar<br>
     global pad winTitle ScipadVersion listoffile<br>
     global MenuEntryId<br>
-    set fname $listoffile("$textarea",displayedname)<br>
-    set ind [extractindexfromlabel $pad.filemenu.wind $fname]<br>
-    set mod1 ""; set mod2 ""<br>
+    global defaultencoding<br>
+<br>
     if {$listoffile("$textarea",readonly) == 1} {<br>
         set mod1 [mc " \[ReadOnly\]"]<br>
+    } else {<br>
+        set mod1 ""<br>
     }<br>
+<br>
     if {[isanymodified]} {<br>
         $pad.statusind configure -background PeachPuff<br>
     } else {<br>
         $pad.statusind configure -background [$pad.filemenu cget -background]<br>
     }<br>
+<br>
+    set fname $listoffile("$textarea",displayedname)<br>
+    set ind [extractindexfromlabel $pad.filemenu.wind $fname]<br>
     if {[ismodified $textarea]} {<br>
         set mod2 [mc " (modified)"]<br>
         if {$ind !=-1} {<br>
@@ -198,25 +204,35 @@<br>
               -activebackground LightSalmon<br>
         }<br>
         $pad.statusind configure -background Salmon<br>
-    } else {<br>
+    } else {<br>
+        set mod2 ""<br>
         if {$ind !=-1} {<br>
             $pad.filemenu.wind entryconfigure $ind -background "" \<br>
                -activebackground ""<br>
         }<br>
     }<br>
+<br>
+    if {$listoffile("$textarea",encoding) != $defaultencoding} {<br>
+        set mod3 " ($listoffile("$textarea",encoding))"<br>
+    } else {<br>
+        set mod3 ""<br>
+    }<br>
+<br>
     if {$panesonly == "false"} {<br>
         # catched because scan will fail when launched from wish<br>
         if {[catch {<br>
             scan $ScipadVersion "%s - %s" ScipadVersionNumber ScipadVersionString<br>
-            wm title $pad "$winTitle $ScipadVersionNumber - $fname$mod1$mod2"<br>
+            wm title $pad "$winTitle $ScipadVersionNumber - $fname$mod1$mod2$mod3"<br>
                    }] } {<br>
-            wm title $pad "$winTitle - $fname$mod1$mod2"<br>
+            wm title $pad "$winTitle - $fname$mod1$mod2$mod3"<br>
         }<br>
     }<br>
+<br>
     if {[isdisplayed $textarea]} {<br>
         [getpaneframename $textarea].panetitle configure \<br>
-          -text "$fname$mod1$mod2"<br>
+          -text "$fname$mod1$mod2$mod3"<br>
     }<br>
+<br>
     if {[ismodified $textarea] && \<br>
           $listoffile("$textarea",thetime) !=0} {<br>
         $pad.filemenu.files entryconfigure \<br>
--- tcl/mainwindow.tcl  Thu Nov 13 21:23:19 2008<br>
+++ tcl/mainwindow.tcl  Sun Dec 14 21:34:40 2008<br>
@@ -42,6 +42,7 @@<br>
 set listoffile("$pad.new$winopened",undostackdepth) 0; # used to enable/disable the undo menu entry<br>
 set listoffile("$pad.new$winopened",redostackdepth) 0; # used to enable/disable the redo menu entry<br>
 set listoffile("$pad.new$winopened",progressbar_id) ""; # colorization progressbar identifier<br>
+set listoffile("$pad.new$winopened",encoding) $defaultencoding<br>
<br>
 set chset()                 {}<br>
 set words()                 {}<br>
--- tcl/menues.tcl      Thu Nov 13 21:23:19 2008<br>
+++ tcl/menues.tcl      Sun Dec 14 22:04:04 2008<br>
@@ -33,6 +33,7 @@<br>
     global Shift_Tab<br>
     foreach c1 "$bgcolors $fgcolors" {global $c1}<br>
     global Tk85<br>
+    global currentencoding<br>
<br>
     #destroy old menues (used when changing language)<br>
     foreach w [winfo children $pad.filemenu] {<br>
@@ -380,7 +381,7 @@<br>
                 -variable lang -value $l -command relocalize"<br>
         }<br>
     }<br>
-# feature temporary disabled as not yet 100% ok (see bindings/issues.txt)<br>
+# feature enabled yet not 100% ok (see bindings/issues.txt) - teasing!<br>
     menu $pad.filemenu.options.bindings -tearoff 0<br>
     eval "$pad.filemenu.options add cascade [me "&Bindings style"] \<br>
            -menu $pad.filemenu.options.bindings "<br>
@@ -405,6 +406,13 @@<br>
         eval "$pad.filemenu.options.messageboxes add radiobutton \<br>
             [me "Copied in a &message box"] \<br>
              -value true -variable ScilabErrorMessageBox"<br>
+    eval "$pad.filemenu.options add cascade [me "Enc&oding"] \<br>
+               -menu $pad.filemenu.options.encodings"<br>
+        menu $pad.filemenu.options.encodings -tearoff 1<br>
+        foreach en [lsort -dictionary [encoding names]] {<br>
+            $pad.filemenu.options.encodings add radiobutton -label $en \<br>
+                -command {setencoding} -value $en -variable currentencoding<br>
+        }<br>
     menu $pad.filemenu.options.exitopts -tearoff 0<br>
     eval "$pad.filemenu.options add cascade [me "E&xit options"] \<br>
            -menu $pad.filemenu.options.exitopts "<br>
--- changelog.txt       Sat Dec 13 15:13:14 2008<br>
+++ changelog.txt       Mon Dec 15 22:43:07 2008<br>
@@ -1,3 +1,9 @@<br>
+Francois VOGEL, 14/12/08<br>
+ * Selection of the file encoding is now possible through a new option menu<br>
+   (this is a request from Yung-Jang Lee) - This is the implementation<br>
+   corresponding to SEP#12<br>
+ * version --> 7.11.SEP12<br>
+<br>
 Francois VOGEL, 13/12/08<br>
  * Fixed bug 3806 (drag and drop fails because package tkdnd is not found)<br>
  * File/Revert did not update the readonly flag. Reverting to the saved state<br>
@@ -40,7 +46,8 @@<br>
    the last peer in the list (instead of the focused peer) did win the title<br>
    bar label<br>
  * Added new command "Create help from head comments" - Initial code and<br>
-   function help_from_sci courtesy of Torbjørn Pettersen<br>
+   function help_from_sci courtesy of Torbjørn Pettersen - This is the<br>
+   implementation corresponding to SEP#9<br>
  * version --> 7.7<br>
<br>
 Francois VOGEL, 03/10/08<br>
--- version.xml Sat Dec 13 15:13:14 2008<br>
+++ version.xml Mon Dec 15 22:43:17 2008<br>
@@ -15,5 +15,5 @@<br>
 --><br>
 <!-- =================== --><br>
<br>
-<VERSION major="7" minor="11" maintenance="0" revision="0" string="SciPad unstable-svn" /><br>
+<VERSION major="7" minor="11" maintenance="SEP12" revision="0" string="SciPad unstable-svn" /><br>
 </MODULE_VERSION><br>
<br></blockquote></div><br>