byte-order-mark junk

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-09-26 21:33:24 +00:00
parent 832448bbea
commit 0108de71ab
1 changed files with 8 additions and 1 deletions

View File

@ -535,6 +535,7 @@ class FileBuffer(Buffer):
Buffer.__init__(self)
self.path = os.path.realpath(path)
self.checksum = None
self.bytemark = ''
if name is None:
self._name = os.path.basename(self.path)
else:
@ -588,10 +589,16 @@ class FileBuffer(Buffer):
data = f.read()
if '\t' in data:
self.writetabs = True
f.close()
self.store_checksum(data)
else:
data = ''
if data.startswith('\xEF\xBB\xBF'):
self.bytemark = data[:2]
data = data[2:]
self.nl = self._detect_nl_type(data)
data = self.read_filter(data)
data = data.replace("\t", " ")
@ -633,7 +640,7 @@ class FileBuffer(Buffer):
data = self.write_filter(data)
f2 = self._open_file_w(temp_path)
f2.write(data)
f2.write(self.bytemark + data)
f2.close()
if self.path_exists():