Permalink
Browse files

Use codecs.open to read text in get_tex_root and makePDF

  • Loading branch information...
1 parent ecc4be1 commit f5c0502585dd8a4d31889cb0c55746e7850d055f @msiniscalchi msiniscalchi committed Jul 9, 2013
Showing with 8 additions and 4 deletions.
  1. +4 −2 getTeXRoot.py
  2. +4 −2 makePDF.py
View
@@ -9,7 +9,7 @@
import os.path, re
-
+import codecs
# Parse magic comments to retrieve TEX root
@@ -44,7 +44,9 @@ def get_tex_root(view):
is_file = False
else:
- lines = open(texFile, "rU")
+ # This works on ST2 and ST3, but does not automatically convert line endings.
+ # We should be OK though.
+ lines = codecs.open(texFile, "r", "UTF-8")
is_file = True
for line in lines:
View
@@ -11,11 +11,12 @@
from . import getTeXRoot
from . import parseTeXlog
-import sublime, sublime_plugin
+import sublime_plugin
import sys, os, os.path, platform, threading, functools
import subprocess
import types
import re
+import codecs
DEBUG = False
@@ -133,6 +134,7 @@ def run ( self ):
# However, we must still decode the resulting lines using the relevant encoding.
# 121101 -- moved splitting and decoding logic to parseTeXlog, where it belongs.
+ # Note to self: need to think whether we don't want to codecs.open this, too...
data = open(self.caller.tex_base + ".log", 'rb').read()
errors = []
@@ -227,7 +229,7 @@ def run(self, cmd="", file_regex="", path=""):
# I actually think self.file_name is it already
self.engine = 'pdflatex' # Standard pdflatex
- for line in open(self.file_name, "rU").readlines():
+ for line in codecs.open(self.file_name, "r", "UTF-8").readlines():
if not line.startswith('%'):
break
else:

0 comments on commit f5c0502

Please sign in to comment.