microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 453 forks source link

Any option can change output encoding to `UTF8` in `DEBUG CONSOLE` panel? #4136

Open Xsakura1314 opened 1 month ago

Xsakura1314 commented 1 month ago

Brief Issue Summary

I want to try debugging and printing some Chinese characters, but the output in the Debug Console panel is incorrect. My file encoding is utf8, system encoding is gbk. I would like to know if there is a CMake Tools or VSCode configuration option can change Debug Console panel to utf8 encoding.

int main(int argc, char *argv[]) {
  qDebug() << "你好1";
  fmt::println("你好2");
  std::cout << "你好3" << std::endl;
  return 0;
}

Image

I have already added the following statements in my CMakeLists.txt,

if (MSVC)
    add_compile_options("/utf-8")
endif()

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

Enviroment

System: Windows 11(x64 23H2 GBK encoding)

Softeware:

Compiler : MSVC2019

Amy-Li03 commented 1 month ago

Hi @Xsakura1314 , thanks for reporting issue here! And could you please set following option to check whether your issue was resolved? "cmake.outputLogEncoding": "utf8"

Xsakura1314 commented 4 weeks ago

@Amy-Li03 Thank you for your response. I have tried your method, and restarted VSCode, but it still does not work properly. Do I need to provide more information?

Image

Amy-Li03 commented 4 weeks ago

@Xsakura1314 thank you for your reply! It seems that your issue is dup with this one: https://github.com/microsoft/vscode-cmake-tools/issues/3632, it is a bug, and our development team will investigate it later. Please confirm if this is same as yours.

Xsakura1314 commented 3 weeks ago

I find a not elegant way to solve the problem, which is change my system encoding to Unicode UTF-8.

Thus I guess the VSCode DEBUG CONSOLE panel is still using GBK encoding instead of UTF-8 encoding when debug via CMake Tools, even though I tried to set it to UTF-8 in the CMakeLists.txt file. In fact , they are not related.

I can't find an option to change the DEBUG CONSOLE panel encoding in VSCode.

May need an option to change it.

Image Image

Amy-Li03 commented 3 weeks ago

Thanks for sharing solution at here! We have linked this issue with #3632 , after that is fixed, please verify this one. Thanks for help us build a better Visual Studio Code!