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"],
Related
I want to use msys2 as a integrated terminal in vscode, so I added this configulation to my user setting.json in vscode.
"terminal.integrated.profiles.windows": {
"MSYS2 UCRT64": {
"path": [
"C:\\msys64\\usr\\bin\\bash.exe",
],
"args": [
"--login",
"-i"
],
"env": {
"MSYSTEM": "UCRT64",
"CHERE_INVOKING": "1",
"MSYS2_PATH_TYPE": "inherit"
}
},
},
"terminal.integrated.defaultProfile.windows": "MSYS2 UCRT64",
And when I open the vscode and toggle terminal window, the msys2 launch, but its start folder is not the same with the one when I launch it from installed location(c/msys64/ucrt64.exe).
shumbow#DESKTOP-STEUAV4 UCRT64 /c/Users/shumbow
$ pwd
/c/Users/shumbow
This is when I launch it from install location.
shumbow#DESKTOP-STEUAV4 UCRT64 ~
$ pwd
/home/shumbow
Could anyone teach me the way I can make these two same?
#HolyBlackCat Removing the CHERE_INVOKING env variable did the trick!(answer by HolyBlackCat). Thanks.
Hi all.
I'm having a problem in integrating a customized zsh shell into vscode and webstorm IDE.
By default, both code editors see the path to zsh at zsh, however, vscode writes
'The terminal process "/home/cstrp/zsh" failed to launch (exit code: 1).' and added path to /usr/bin/zsh vscode writes: 'Value is not accepted. Valid values: null, "sh", "bash", "sh (2)", "bash (2)", "JavaScript Debug Terminal".(1)'
config vsCode
"terminal.integrated.profiles.linux": {
"bash": null,
"zsh": {
"path": "zsh",
"args": [
"-l"
]
},
},
// "terminal.integrated.linux": "zsh",
"terminal.integrated.automationProfile.linux": {
"path": "zsh",
},
default shell
my pc
It was only necessary on behalf of the super user to install all the code editors in the right place
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
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\"",
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