Set encoding for all text reads and writes to utf8, as windows defaults to latin1
This commit is contained in:
@@ -53,7 +53,7 @@ class NWDoc():
|
||||
|
||||
if path.isfile(docPath):
|
||||
try:
|
||||
with open(docPath,mode="r") as inFile:
|
||||
with open(docPath,mode="r",encoding="utf8") as inFile:
|
||||
theDoc = inFile.read()
|
||||
except Exception as e:
|
||||
self.makeAlert(["Failed to open document file.",str(e)], nwAlert.ERROR)
|
||||
@@ -89,7 +89,7 @@ class NWDoc():
|
||||
if path.isfile(docPath): rename(docPath,docBack)
|
||||
|
||||
try:
|
||||
with open(docPath,mode="w") as outFile:
|
||||
with open(docPath,mode="w",encoding="utf8") as outFile:
|
||||
outFile.write(docText)
|
||||
except Exception as e:
|
||||
self.makeAlert(["Could not save document.",str(e)], nwAlert.ERROR)
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ class NWIndex():
|
||||
if path.isfile(indexFile):
|
||||
logger.debug("Loading index file")
|
||||
try:
|
||||
with open(indexFile,mode="r") as inFile:
|
||||
with open(indexFile,mode="r",encoding="utf8") as inFile:
|
||||
theJson = inFile.read()
|
||||
theData = json.loads(theJson)
|
||||
except Exception as e:
|
||||
@@ -119,7 +119,7 @@ class NWIndex():
|
||||
else:
|
||||
nIndent = None
|
||||
try:
|
||||
with open(indexFile,mode="w+") as outFile:
|
||||
with open(indexFile,mode="w+",encoding="utf8") as outFile:
|
||||
outFile.write(json.dumps({
|
||||
"tagIndex" : self.tagIndex,
|
||||
"refIndex" : self.refIndex,
|
||||
|
||||
@@ -328,7 +328,7 @@ class NWProject():
|
||||
# Write the xml tree to file
|
||||
saveFile = path.join(self.projPath,self.projFile)
|
||||
try:
|
||||
with open(saveFile,"wb") as outFile:
|
||||
with open(saveFile,mode="wb") as outFile:
|
||||
outFile.write(etree.tostring(
|
||||
nwXML,
|
||||
pretty_print = True,
|
||||
@@ -657,7 +657,7 @@ class NWProject():
|
||||
if self.projMeta is None:
|
||||
return False
|
||||
|
||||
with open(path.join(self.projMeta, nwFiles.SESS_INFO), mode="a+") as outFile:
|
||||
with open(path.join(self.projMeta, nwFiles.SESS_INFO),mode="a+",encoding="utf8") as outFile:
|
||||
print((
|
||||
"Start: {opened:s} "
|
||||
"End: {closed:s} "
|
||||
|
||||
Reference in New Issue
Block a user