James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.66k stars 530 forks source link

CJK-encoded paths&filename cause garbled characters in the output window #3518

Closed ZhenyuXiao closed 1 year ago

ZhenyuXiao commented 1 year ago

Preliminary questions [Required]

Disable all the other extensions except for LaTeX Workshop, restart VS Code, and check that you still see this issue. [Required]

You still see this issue?: Yes

Make sure to visit the wiki FAQ before filling an issue.

You visited the wiki?: Yes

If your issue is with compiling a document (not having to do with finding the root file of a project), check first that you can compile manually.

You can compile a TeX document manually?: Yes

Describe the bug [Required]

The .tex file name is encoded in Chinese, and the path is in English. There is no custom compilation tool, the file is compiled using the default tool, and the PDF file is successfully generated. However, the Latex compiler output window produces garbled characters.

To Reproduce

Steps to reproduce the behavior:

  1. Create a file whose encoding is chinese, e.g. "你好.tex". Then Put it in the english-encoded Path.
  2. Use default tool to compile this file.
  3. See output in the "Latex Compiler" output panel, you will find the garbled characters which exactly correspond to this Chinese name.

Expected behavior

The output window correctly outputs Chinese characters.

Logs [Required]

see LaTeX Workshop Output [Required]

LaTeX Workshop Output [Required]

[17:13:17] Initializing LaTeX Workshop. [17:13:17] Extension root: c:\Users\Thor.vscode\extensions\james-yu.latex-workshop-8.29.0 [17:13:17] $PATH: C:\Program Files\Python310\Scripts\;C:\Program Files\Python310\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Bluetooth Command Line Tools\bin;C:\Program Files (x86)\Windows Kits\10\Debuggers\x64;C:\Program Files (x86)\Windows Kits\10\Debuggers\x86;C:\Program Files\texlive\2022\bin\win32;C:\Program Files\Microsoft Network Monitor 3\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2022.1.1\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\dotnet\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\msys64\ucrt64\bin;C:\Program Files\msys64\mingw64\bin;C:\Program Files\msys64\usr\bin;C:\Program Files\Microsoft VS Code Insiders\bin;C:\Program Files\Git\cmd;C:\Program Files\PowerShell\7\;C:\Users\Thor\scoop\apps\openjdk\current\bin;C:\Users\Thor\scoop\apps\gsudo\current;C:\Users\Thor\scoop\apps\cuda\current\bin;C:\Users\Thor\scoop\apps\python27\current\Scripts;C:\Users\Thor\scoop\apps\python27\current;C:\Users\Thor\scoop\shims;C:\Users\Thor\AppData\Local\Microsoft\WindowsApps;C:\Users\Thor.dotnet\tools;C:\Users\Thor\AppData\Roaming\Python\Python310\Scripts [17:13:17] $SHELL: undefined [17:13:17] $LANG: undefined [17:13:17] $LC_ALL: undefined [17:13:17] process.platform: win32 [17:13:17] process.arch: x64 [17:13:17] vscode.env.appName: Visual Studio Code [17:13:17] vscode.env.remoteName: undefined [17:13:17] vscode.env.uiKind: 1 [17:13:17] Configuration for workspace: file:///c:/Develop/CodeStart [17:13:17] editor.acceptSuggestionOnEnter: "on" [17:13:17] latex-workshop.bind.enter.key: true [17:13:17] latex-workshop.docker.enabled: false [17:13:17] latex-workshop.docker.image.latex: "" [17:13:17] latex-workshop.hover.preview.mathjax.extensions: [] [17:13:17] latex-workshop.intellisense.package.enabled: true [17:13:17] latex-workshop.intellisense.update.aggressive.enabled: false [17:13:17] latex-workshop.intellisense.update.delay: 1000 [17:13:17] latex-workshop.latex.autoBuild.run: "onFileChange" [17:13:17] latex-workshop.latex.build.forceRecipeUsage: true [17:13:17] latex-workshop.latex.outDir: "%DIR%" [17:13:17] latex-workshop.latex.recipes: [ { "name": "latexmk 🔃", "tools": [ "latexmk" ] }, { "name": "latexmk (latexmkrc)", "tools": [ "latexmk_rconly" ] }, { "name": "latexmk (lualatex)", "tools": [ "lualatexmk" ] }, { "name": "latexmk (xelatex)", "tools": [ "xelatexmk" ] }, { "name": "pdflatex ➞ bibtex ➞ pdflatex × 2", "tools": [ "pdflatex", "bibtex", "pdflatex", "pdflatex" ] }, { "name": "Compile Rnw files", "tools": [ "rnw2tex", "latexmk" ] }, { "name": "Compile Jnw files", "tools": [ "jnw2tex", "latexmk" ] }, { "name": "tectonic", "tools": [ "tectonic" ] } ] [17:13:17] latex-workshop.latex.tools: [ { "name": "latexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf", "-outdir=%OUTDIR%", "%DOC%" ], "env": {} }, { "name": "lualatexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-lualatex", "-outdir=%OUTDIR%", "%DOC%" ], "env": {} }, { "name": "xelatexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-xelatex", "-outdir=%OUTDIR%", "%DOC%" ], "env": {} }, { "name": "latexmk_rconly", "command": "latexmk", "args": [ "%DOC%" ], "env": {} }, { "name": "pdflatex", "command": "pdflatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%" ], "env": {} }, { "name": "bibtex", "command": "bibtex", "args": [ "%DOCFILE%" ], "env": {} }, { "name": "rnw2tex", "command": "Rscript", "args": [ "-e", "knitr::opts_knit$set(concordance = TRUE); knitr::knit('%DOCFILE_EXT%')" ], "env": {} }, { "name": "jnw2tex", "command": "julia", "args": [ "-e", "using Weave; weave(\"%DOC_EXT%\", doctype=\"tex\")" ], "env": {} }, { "name": "jnw2texmintex", "command": "julia", "args": [ "-e", "using Weave; weave(\"%DOC_EXT%\", doctype=\"texminted\")" ], "env": {} }, { "name": "tectonic", "command": "tectonic", "args": [ "--synctex", "--keep-logs", "%DOC%.tex" ], "env": {} } ] [17:13:17] latex-workshop.viewer.pdf.internal.keyboardEvent: "auto" [17:13:17] Creating a new file watcher. [17:13:17] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{"stabilityThreshold":250}} [17:13:17] Creating PDF file watcher. [17:13:17] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{}} [17:13:17] Creating Bib file watcher. [17:13:17] watcherOptions: {"useFsEvents":false,"usePolling":false,"interval":300,"binaryInterval":1000,"awaitWriteFinish":{"stabilityThreshold":250}} [17:13:17] Set $LATEXWORKSHOP_DOCKER_LATEX: "" [17:13:18] [Server] Creating LaTeX Workshop http and websocket server. [17:13:18] LaTeX Workshop initialized. [17:13:18] Trigger characters for intellisense of LaTeX documents: ["\",",","{"] [17:13:18] Bibtex format config: {"tab":" ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]} [17:13:18] Current workspace folders: ["file:///c:/Develop/CodeStart"] [17:13:18] Found root file from active editor: c:\Develop\CodeStart\Go\Tex\Text\你好.tex [17:13:18] Root file changed: from undefined to c:\Develop\CodeStart\Go\Tex\Text\你好.tex [17:13:18] Start to find all dependencies. [17:13:18] Root file languageId: latex [17:13:18] [Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":6222} [17:13:18] Reset file watcher. [17:13:18] Parsing a file and its subfiles: c:\Develop\CodeStart\Go\Tex\Text\你好.tex [17:13:18] Parse fls file. [17:13:18] Cannot find fls file: c:\Develop\CodeStart\Go\Tex\Text\你好.fls [17:13:18] Added to file watcher: c:\Develop\CodeStart\Go\Tex\Text\你好.tex [17:13:18] Snippet data loaded. [17:13:18] [Server] valdOrigin is http://127.0.0.1:6222 [17:13:18] Checking for duplicate labels: c:\Develop\CodeStart\Go\Tex\Text\你好.tex. [17:13:20] Manager.fileWatcher.getWatched: {"c:\Develop\CodeStart\Go\Tex\Text":["你好.tex"]} [17:13:20] Manager.filesWatched: ["c:\Develop\CodeStart\Go\Tex\Text\你好.tex"] [17:13:20] BibWatcher.bibWatcher.getWatched: {} [17:13:20] BibWatcher.bibsWatched: [] [17:13:20] PdfWatcher.pdfWatcher.getWatched: {} [17:13:20] PdfWatcher.pdfsWatched: [] [17:13:20] PdfWatcher.watchedPdfVirtualUris: [] [17:13:20] PdfWatcher.ignoredPdfUris: [] [17:13:25] Current workspace folders: ["file:///c:/Develop/CodeStart"] [17:13:25] Found root file from active editor: c:\Develop\CodeStart\Go\Tex\Text\你好.tex [17:13:25] Keep using the same root file: c:\Develop\CodeStart\Go\Tex\Text\你好.tex [17:13:28] BUILD command invoked. [17:13:28] The document of the active editor: file:///c:/Develop/CodeStart/Go/Tex/Text/你好.tex [17:13:28] The languageId of the document: latex [17:13:28] Current workspace folders: ["file:///c:/Develop/CodeStart"] [17:13:28] Found root file from active editor: c:\Develop\CodeStart\Go\Tex\Text\你好.tex [17:13:28] Keep using the same root file: c:\Develop\CodeStart\Go\Tex\Text\你好.tex [17:13:28] Building root file: c:\Develop\CodeStart\Go\Tex\Text\你好.tex [17:13:28] Build root file c:\Develop\CodeStart\Go\Tex\Text\你好.tex [17:13:28] outDir: c:/Develop/CodeStart/Go/Tex/Text [17:13:28] Found TeX program by magic comment: xelatex [17:13:28] Recipe step 1: latexmk [17:13:28] Recipe step 1 args: ["-synctex=1","-interaction=nonstopmode","-file-line-error","-pdf","-outdir=c:/Develop/CodeStart/Go/Tex/Text","c:/Develop/CodeStart/Go/Tex/Text/你好"] [17:13:28] Recipe step env: {} [17:13:28] cwd: c:\Develop\CodeStart\Go\Tex\Text [17:13:28] LaTeX build process spawned. PID: 18052. [17:14:02] LaTeX log parsed with 0 messages. [17:14:02] Recipe of length 1 finished. PID: 18052. [17:14:02] Successfully built c:\Develop\CodeStart\Go\Tex\Text\你好.tex. [17:14:02] Call refreshExistingViewer: {"sourceFile":"c:\Develop\CodeStart\Go\Tex\Text\你好.tex"} [17:14:02] Not found PDF viewers to refresh: file:///c%3A/Develop/CodeStart/Go/Tex/Text/%E4%BD%A0%E5%A5%BD.pdf [17:14:02] Parse fls file. [17:14:02] Fls file found: c:\Develop\CodeStart\Go\Tex\Text\你好.fls [17:14:02] Parse aux file: c:\Develop\CodeStart\Go\Tex\Text\你好.aux [17:14:03] Added to file watcher: c:\Windows\Fonts\simhei.ttf [17:14:03] Added to file watcher: c:\Windows\Fonts\simsun.ttc [17:14:03] Added to file watcher: c:\Windows\Fonts\simkai.ttf [17:14:03] Added to file watcher: c:\Windows\Fonts\msyh.ttc [17:30:09] LOG command invoked: default

Developer Tools Console [Required]

To access the log, click 'help' -> 'Toggle Developer Tools' -> 'Console'. Paste anything suspicious.

[Paste the log here]

LaTex compiler log

See Screenshots, you can see the garbled characters.

Screenshots

image

Desktop [Required]

Please write exact version numbers. Please don't write latest instead of exact numbers.

Additional questions

Are you using VSCodium?

No

Are you using the Snap or Flatpack versions of VS Code?

No

Are you using LaTeX Workshop with VS Code Remote?

No

If the answer is Yes, please write which one you are using. Write the versions of the remote extension.

Additional context

Add any other context about the problem here.

James-Yu commented 1 year ago

Likely to be a latex issue, instead of the extension’s. You are advised to not use CJK chars in path.