FileBrowser.st
changeset 5514 a9e6eb4214bd
parent 5513 4cf44154150d
child 5515 3ff121346fc1
--- a/FileBrowser.st	Fri Feb 13 01:42:29 2004 +0100
+++ b/FileBrowser.st	Fri Feb 13 01:49:48 2004 +0100
@@ -6367,7 +6367,7 @@
 !
 
 writeFile:fileName text:someText encoding:encoding
-    |stream msg startNr nLines string|
+    |stream msg startNr nLines string encoder|
 
     [
         stream := (currentDirectory filenameFor:fileName) writeStream.
@@ -6377,26 +6377,20 @@
         ^ self.
     ].
 
+    encoder := CharacterEncoder encoderToEncodeFrom:(subView characterEncoding) into:encoding.
+
     dosEOLMode value == true ifTrue:[
         stream eolMode:#crlf.
         "/ must do it lineWise ...
         someText asStringCollection do:[:line |
             line notNil ifTrue:[
-                string := line.
-                encoding notNil ifTrue:[
-                    string := string encodeInto:encoding
-                ].
-                stream nextPutAll:line
+                stream nextPutAll:(encoder encodeString:line)
             ].
             stream cr
         ]
     ] ifFalse:[
         (someText isString) ifTrue:[
-            string := someText.
-            encoding notNil ifTrue:[
-                string := string encodeInto:encoding
-            ].
-            stream nextPutAll:string.
+            stream nextPutAll:(encoder encodeString:someText).
         ] ifFalse:[
             "/
             "/ on some systems, writing linewise is very slow (via NFS)
@@ -6409,10 +6403,7 @@
                 string := someText asStringWithCRsFrom:startNr
                                                     to:((startNr + 1000) min:nLines)
                                           compressTabs:compressTabs.
-                encoding notNil ifTrue:[
-                    string := string encodeInto:encoding
-                ].
-                stream nextPutAll:string.
+                stream nextPutAll:(encoder encodeString:string).
                 startNr := startNr + 1000 + 1.
             ].
         ].
@@ -7621,5 +7612,5 @@
 !FileBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.567 2004-02-13 00:42:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.568 2004-02-13 00:49:48 cg Exp $'
 ! !