microsoft / microsoft/vscode-cpptools
debugger cannot show chinese characters from a string variable
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
#include <bits/stdc++.h>
using namespace std;
string replace(string line, string o, string n) {
auto i = line.find(o);
if (i != string::npos) {
return line.replace(i, o.length(), n);
}
return line;
}
int main() {
string line;
cout << "> ";
while (getline(cin, line)) {
line = replace(line, "你", "我");
line = replace(line, "吗", "");
line = replace(line, "?", "");
line = replace(line, "?", "");
cout << line << endl;
cout << "> ";
}
}
I try to debug these code above and input "你好吗" to line but the debugger cannot show its content properly.
It seem a matter of gdb problem, if so, what can I do to fix it?
my config is as follow
{
"name": "desktop debug",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\sdk\\mingw64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
],
"preLaunchTask": "g++.exe build active file"
}
➜ g++ --version
g++.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
➜ gdb --version
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
plugin version
0.29.0-insiders
os version
20H2 (os 内部版本 19042.330)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in VS Code using the supplied C++ program, launch configuration, MinGW GDB 8.1, and Windows environment. Start by checking how the C++ extension renders the line variable in the debugger, then compare the displayed value with the Chinese input. Done means Chinese characters from the string are shown correctly during debugging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100