CharacterEncoder.st
branchjv
changeset 18768 99079a967eb0
parent 18630 a74d669db937
parent 18762 4b2d5801f66c
child 18807 d79ce9fb5198
equal deleted inserted replaced
18767:642ad83732c9 18768:99079a967eb0
  1215         encoding #name
  1215         encoding #name
  1216      or:
  1216      or:
  1217         encoding: name
  1217         encoding: name
  1218      within the given buffer 
  1218      within the given buffer 
  1219      (which is usually the first few bytes of a textFile).
  1219      (which is usually the first few bytes of a textFile).
  1220      If thats not found, use heuristics (in CharacterArray) to guess."
  1220      If thats not found, use heuristics (in CharacterArray) to guess.
       
  1221      Return a symbol like #utf8."
  1221 
  1222 
  1222     |s buffer n "{Class: SmallInteger }"|
  1223     |s buffer n "{Class: SmallInteger }"|
  1223 
  1224 
  1224     s := aFilename asFilename readStreamOrNil.
  1225     s := aFilename asFilename readStreamOrNil.
  1225     s isNil ifTrue:[^ nil].
  1226     s isNil ifTrue:[^ nil].
  1242 guessEncodingOfStream:aStream
  1243 guessEncodingOfStream:aStream
  1243     "look for a string of the form
  1244     "look for a string of the form
  1244             encoding #name
  1245             encoding #name
  1245      or:
  1246      or:
  1246             encoding: name
  1247             encoding: name
  1247      in the first few bytes of aStream."
  1248      in the first few bytes of aStream.
       
  1249      Return a symbol like #utf8."
  1248 
  1250 
  1249     |oldPosition buffer n|
  1251     |oldPosition buffer n|
  1250 
  1252 
  1251     buffer := String new:64.
  1253     buffer := String new:64.
  1252 
  1254