File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1013,17 +1013,23 @@ def find_tex_file(filename, format=None):
10131013 if isinstance (format , bytes ):
10141014 format = format .decode ('utf-8' , errors = 'replace' )
10151015
1016+ if os .name == 'nt' :
1017+ # On Windows only, kpathsea can use utf-8 for cmd args and output.
1018+ # The `command_line_encoding` environment variable is set to force it
1019+ # to always use utf-8 encoding. See mpl issue #11848 for more info.
1020+ kwargs = dict (env = dict (os .environ , command_line_encoding = 'utf-8' ))
1021+ else :
1022+ kwargs = {}
1023+
10161024 cmd = ['kpsewhich' ]
10171025 if format is not None :
10181026 cmd += ['--format=' + format ]
10191027 cmd += [filename ]
10201028 try : # Below: strip final newline.
1021- result = cbook ._check_and_log_subprocess (cmd , _log )[:- 1 ]
1029+ result = cbook ._check_and_log_subprocess (cmd , _log , ** kwargs )[:- 1 ]
10221030 except RuntimeError :
10231031 return ''
10241032 if os .name == 'nt' :
1025- # On Windows only, kpathsea appears to use utf-8 output(?); see
1026- # __win32_fputs in the kpathsea sources and mpl issue #11848.
10271033 return result .decode ('utf-8' )
10281034 else :
10291035 return os .fsdecode (result )
You can’t perform that action at this time.
0 commit comments