FileBrowser.st
changeset 5683 a5248db0d6bb
parent 5678 9601736c2453
child 5693 6193522a042b
--- a/FileBrowser.st	Tue Mar 09 22:08:44 2004 +0100
+++ b/FileBrowser.st	Tue Mar 09 22:42:04 2004 +0100
@@ -1467,7 +1467,7 @@
      If thats not found, use heuristics (in CharacterArray) to guess."
 
     |s buffer n "{Class: SmallInteger }"
-     binary idx w withoutQuotes isHTML lcBuffer enc|
+     binary enc|
 
     s := aFilename readStreamOrNil.
     s isNil ifTrue:[^ nil].
@@ -1477,46 +1477,10 @@
     n := s nextBytes:n into:buffer.
     s close.
 
+    enc := SourceCodeManagerUtilities guessEncodingOfBuffer:buffer.
+    enc notNil ifTrue:[^ enc].
+
     binary := false.
-
-    withoutQuotes := 
-        [ 
-            ((w startsWith:$") or:[(w startsWith:$')]) ifTrue:[
-                w := w copyFrom:2
-            ].
-            ((w endsWith:$") or:[(w endsWith:$')]) ifTrue:[
-                w := w copyWithoutLast:1
-            ].
-            w
-        ].
-
-    lcBuffer := buffer asLowercase.
-
-    #( 'charset' 'encoding' ) do:[:keyWord |
-        (idx := lcBuffer findString:keyWord) ~~ 0 ifTrue:[
-            s := ReadStream on:buffer.
-            s position1Based:idx.
-            s skip:keyWord size.
-            s skipSeparators. 
-
-            ['=:#' includes:s peek] whileTrue:[
-                s next.
-                s skipSeparators. 
-            ].
-            s skipSeparators. 
-            w := s upToSeparator.
-            w notNil ifTrue:[
-                enc := withoutQuotes value.
-                (CharacterEncoder encoderFor:enc ifAbsent:nil) notNil ifTrue:[
-                    ^ enc
-                ].
-                enc size >=3 ifTrue:[
-                    Transcript showCR:'Unknown encoding: ' , withoutQuotes value.
-                ]
-            ].
-        ].
-    ].
-
     1 to:n do:[:i |
         (buffer at:i) isPrintable ifFalse:[binary := true].
     ].
@@ -7523,5 +7487,5 @@
 !FileBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.587 2004-03-09 15:42:26 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.588 2004-03-09 21:42:04 cg Exp $'
 ! !