Windows: use wide char interfaces
Exchange file names and command line parameters with the system using wchar_t interfaces: allows preserving values which can be reversibly transcoded in the current multibyte charset (which can't be UTF-8). Store all file paths internally in UTF-8
This commit is contained in:
@@ -61,7 +61,7 @@ class Executor(RclBaseHandler):
|
||||
return True, postproc.wrapData()
|
||||
else:
|
||||
try:
|
||||
fullcmd = cmd + [filename]
|
||||
fullcmd = cmd + [rclexecm.subprocfile(filename)]
|
||||
proc = subprocess.Popen(fullcmd,
|
||||
stdout = subprocess.PIPE)
|
||||
stdout = proc.stdout
|
||||
|
||||
+13
-1
@@ -29,13 +29,25 @@ import shutil
|
||||
import getopt
|
||||
import rclconfig
|
||||
|
||||
PY3 = sys.version > '3'
|
||||
PY3 = (sys.version > '3')
|
||||
_mswindows = (sys.platform == "win32")
|
||||
|
||||
def makebytes(data):
|
||||
if type(data) == type(u''):
|
||||
return data.encode("UTF-8")
|
||||
return data
|
||||
|
||||
def subprocfile(fn):
|
||||
# On Windows PY3 the list2cmdline() method in subprocess assumes that
|
||||
# all args are str, and we receive file names as UTF-8. So we need
|
||||
# to convert.
|
||||
# On Unix all list elements get converted to bytes in the C
|
||||
# _posixsubprocess module, nothing to do
|
||||
if PY3 and _mswindows:
|
||||
return fn.decode('UTF-8')
|
||||
else:
|
||||
return fn
|
||||
|
||||
my_config = rclconfig.RclConfig()
|
||||
|
||||
############################################
|
||||
|
||||
@@ -479,7 +479,8 @@ class PDFExtractor:
|
||||
print("RECFILTERROR HELPERNOTFOUND pdftotext")
|
||||
sys.exit(1);
|
||||
|
||||
self.filename = params["filename:"]
|
||||
self.filename = rclexecm.subprocfile(params["filename:"])
|
||||
|
||||
#self.em.rclog("openfile: [%s]" % self.filename)
|
||||
self.currentindex = -1
|
||||
self.attextractdone = False
|
||||
|
||||
Reference in New Issue
Block a user