Correct display Cyrillic symbols in SublimeREPL PowerShell - encoding

Summary
I can not to make correct display Cyrillic symbols in SublimeREPL PowerShell.
Expected behavior
In Windows PowerShell I have not this problem.
Actual behavior
Cyrillic symbols always not displayed for me. I see mojibake instead it.
Steps to reproduce
The problem is reproduced for me in a version of Sublime Text without plugins and user settings.
Preferences → Key Bindings → I change Default (Windows).sublime-keymap - User:
[
{
"keys": ["super+alt+p"],
"command": "repl_open",
"args": {
"type": "powershell",
"encoding": "utf-8",
"cmd": ["powershell", "-"],
"cwd": "$file_path",
"external_id": "powershell"
}
}
]
When test.md in my E:\Киролайна folder is opened, I press Super+Alt+P → I get actual behavior.
Not helped
I saw in my PowerShell settings. I have 866 (OEM - русская) encoding.
I change encoding: I run in PowerShell command chcp 65001:
PS E:\Киролайна> chcp 65001
Active code page: 65001
PS E:\Киролайна> chcp
Active code page: 65001
PS E:\Киролайна>
But problem is remained for me.
I try to change encoding in my keymap file:
"encoding": "$win_cmd_encoding"
"encoding": "cp866"
"encoding": "cp1251"
When I press Super+Alt+P in open file, I get error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8a in position 9: invalid start byte
error: UnicodeDecodeError('utf-8', b'C:\Users\\x8a\xae\xe2\AppData\Roaming', 9, 10, 'invalid start byte')
Correct path is C:\Users\Кот\AppData\Roaming, path contain Cyrillic symbols Кот.
Environment
Operating system and version:
Russian Windows 32-bit 10.0.14393
Sublime Text:
Build 3126

Related

How to fix Visual Studio Code distorting characters on Windows?

I have problems with Swedish national characters when using Rust in Visual Studio Code in Windows 11. It can be shown with the following program:
fn main() {
let abc = " ååå
ööö
äää";
println!("<---{}--->", abc);
}
When the program is run from the command line using cargo run, the output is as follows:
<--- ååå
ööö
äää--->
Strangely, spaces are added at the beginning of lines 2 and 3. However, when the program is run in Visual Studio Code, the Swedish characters get distorted.
<--- ååå
├╢├╢├╢
äää--->
How can I solve it? I work with text processing and this is a major problem.
EDIT: Since the problem doesn't appear on many systems, I add the technical data: Windows 11 Pro Version 10.0.22621 Build 22621;
Visual Studio Code Version: 1.73.1 (user setup) Date: 2022-11-09 Chromium: 102.0.5005.167 Node.js: 16.14.2 Sandboxed: No.
- This answer is Windows specific. -
INFO: This answer describes you how can change your VSCode settings to force UTF-8 in your console. An alternative to this answer would be to force UTF-8 system-wide, as described here: Using UTF-8 Encoding (CHCP 65001) in Command Prompt / Windows Powershell (Windows 10)
It seems that sometimes the Windows shell doesn't use the correct UTF-8 code page.
You can tell VSCode to force a codepage in its shell using the following settings.
Open the Settings page (Shortkey: Ctrl+,)
Click on the button on the top right whose mouse-over text reads "Open Settings (JSON)"
Add the following lines:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell",
"args": [
"-NoExit",
"/c",
"chcp.com 65001"
]
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [
"/K",
"chcp 65001"
],
"icon": "terminal-cmd"
},
},
This will force the UTF-8 code page.
If it worked, opening a new shell should display Active code page: 65001.
Source: https://github.com/microsoft/vscode/issues/19837
Previous, deprecated settings:
If your shell is "CMD":
"terminal.integrated.shellArgs.windows": ["/K", "chcp 65001"],
If your shell is "Powershell":
"terminal.integrated.shellArgs.windows": ["-NoExit", "/c", "chcp.com 65001"],

VSCode debugger having issues with character encoding

This question was asked before here but there is no answers on this questions.
When trying to debug char or string type, the debugger prints <error reading variable> or Converting character sets: Invalid argument respectively instead of its value.
This problem can be fixed by running -exec set charset UTF-8 from the debug console while debugging but it is only a temporary fix, and has to be run every time on debugger startup manually.
Is there a way to permanently fix this issue? (I'd prefer not to change any system settings)
In the Launch.json file, adding set charset UTF-8 to the setupCommands fixed it.
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"text": "set charset UTF-8"
}
]

LaTeX Workshop does'nt work well (Recipe terminated with error.)

Problem
I fail to build the LaTeX document on the VScode with LaTeX Workshop.
More preciously, ctrl + S can save the document but can't build the pdf. VScode warns "Recipe terminated with error".
The thing is that I was able to build the LaTeX documents earlier, but yesterday it abruptly didn't work well. Although I didn't change any option about LaTeX, I changed some settings about Python. For example, I uninstalled Anaconda and tried to create virtual environment of python with pipenv. However, I don't think those change are related to this problem...
settings.json
settings.json is as following.
{
"editor.suggest.snippetsPreventQuickSuggestions": false,
// ---------- LaTeX Workshop ----------
"latex-workshop.intellisense.package.enabled": true,
"latex-workshop.message.log.show": true,
"latex-workshop.message.badbox.show": true,
"latex-workshop.latex.autoClean.run": "onBuilt",
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.recipes": [{
"name": "ptex2pdf",
"tools": [
"ptex2pdf"
]
}],
"latex-workshop.latex.tools": [{
"name": "ptex2pdf",
"command": "ptex2pdf",
"args": [
"-l",
"-ot",
"-kanji=utf8 -synctex=1 -interaction=nonstopmode",
"%DOC%"
]
}],
"latex-workshop.message.latexlog.exclude":["(Font shape `(JY1|JT1|JY2|JT2)(/.*)(sl|it|sc)'.*|Some font shapes were not available.*)"]
}
Additional information
Since I hadn't used Workspace of VScode yet, but yesterday I started to use that. Since I thought it
may be the reason of the problem, now I stop using the worspace, but the situation doesn't change.
Furthermore, if I run on the cmd on VScode,
platex hoge.tex
dvipdfmx hoge.dvi
the pdf was outputted successfully.
environment
Windows10 Home
VScode 1.49.0
LaTeX Workshop 8.13.2

Enable xelatex in Latex Workshops for Visual Studio Code

I have a template, which defines all the typesetting recommendations for thesis, but it uses xelatex for compilation. I want to continue using VS Code with Latex Workshops, question is how to change compiler to xelatex from pdflatex. The last one cause next error log:
C:\Users\User\AppData\Local\Programs\MiKTeX 2.9\tex/latex/fontspec\fontspec.sty:45: Fatal Package fontspec Error: The
fontspec package requires either XeTeX or
(fontspec) LuaTeX.
(fontspec)
(fontspec) You must change your typesetting engine to,
(fontspec) e.g., "xelatex" or "lualatex"instead of
(fontspec) "latex" or "pdflatex".
The simplest solution found in issues here, but in more common formulation:
Copying the content, simply go to Preferences → Extensions → LaTeX (meaning LaTeX is LaTeX workshops), find gear-wheel button with name Manage, then find in the list link to settings.json under any tag, open and type next:
"latex-workshop.latex.tools": [{
"name": "latexmk",
"command": "latexmk",
"args": [
"-xelatex",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}],
Reloading the VSCode may be needed.
Also setting.json file could be found in C:\Users\*\AppData\Roaming\Code\User\settings.json.
Use magic comments
add the following line to the beginning of your document.
% !TEX program = xelatex
To enable magic comments, change the setting forceRecipeUsage to false.
I kept getting errors with the other solutions, apparently because I was using backend=biber in my latex code. The following configuration assumes a current MiKTeX setup (including biber) and fixes those problems (also, this does not rely on latexmk). The config uses some inspiration from that of TeXworks.
Inside latex-workshop.latex.tools
{
"name": "xelatex",
"command": "xetex",
"args": [
"-undump=xelatex",
"%DOC%.tex"
],
"env": {}
},
{
"name": "biber",
"command": "biber",
"args": [
"%DOC%"
],
"env": {}
}
Then inside latex-workshop.latex.recipes add the recipe:
{
"name": "xelatex ➞ biber ➞ xelatex x 2x",
"tools": [
"xelatex",
"biber",
"xelatex",
"xelatex"
]
}
Happy texing!

Using visual studio code and running tasks where path to .exe contains a space

I am following the walkthrough from the microsoft docs for using typescript in a vs code project. When I try and run the build task, the terminal comes up with
Executing task: c:\whatever\my path with spaces\Projects\ProjectName\node_modules.bin\tsc.cmd -p "c:\whatever\my path with spaces\Projects\ProjectName\tsconfig.json"
and the error
'c:\whatever\my' is not recognized as an internal or external command,
That is, the space in the folder name is confusing the task runner. I need something like
call "c:\whatever\my path with spaces\Projects\ProjectName\node_modules\.bin\tsc.cmd" -p "c:\whatever\my path with spaces\Projects\ProjectName\tsconfig.json"
How do I set up VS Code so the terminal recieves an input it can interpret with spaces in the directory name? Thank you
current tasks.json:
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
Try using ''-s to escape the string containing the spaces:
in terminal: c:\whatever\'my path with
spaces'\Projects\ProjectName\tsconfig.json
in .json: "command":
"c:\\whatever\\'my path with
spaces'\\Projects\\ProjectName\\tsconfig.json"
You should use quotation marks \" (slash + quotation mark) for the entire command as in
"command": "\"c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe\"",