Repository: pytorch
Issue: Potential decode errors using the MSVC compiler in windows platforms
Labels: module: windows,triaged,oncall: pt2,module: inductor

### 🐛 Describe the bug

Problem description:
I am using unofficially supported triton to enable the torch.complite() feature on Windows.
https://github.com/woct0rdho/triton-windows

As far as I know, it attempts to compile using MSVC on Windows.
I encountered the same error:https://github.com/pytorch/pytorch/issues/130668

I guess this is because MSVC uses the utf16 encoding format as the console output.
See:https://learn.microsoft.com/zh-cn/cpp/build/reference/unicode-support-in-the-compiler-and-linker?view=msvc-170

For example, it runs on my personal computer:
```
PS C:\> cl
用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.42.34433 版
版权所有(C) Microsoft Corporation。保留所有权利。

用法: cl [ 选项... ] 文件名... [ /link 链接选项... ]
```

A search on github shows three places where this code is used:
repo:pytorch/pytorch SUBPROCESS_DECODE_ARGS

This is the main code that causes errors:
https://github.com/pytorch/pytorch/blob/ecf3bae40a6f2f0f3b237bde1fc4b2492765ab13/torch/_inductor/cpp_builder.py#L62

Changing utf8 to cp936 could solve this problem, but more extensive testing is needed, and we need to start thinking about multi-coding support at the code level in preparation for future windows support.

I investigated a merge to 2020, also to address non-English decoding errors:
https://github.com/pytorch/pytorch/pull/49020
https://github.com/pytorch/pytorch/blob/ecf3bae40a6f2f0f3b237bde1fc4b2492765ab13/torch/utils/cpp_extension.py#L45
https://github.com/pytorch/pytorch/blob/ecf3bae40a6f2f0f3b237bde1fc4b2492765ab13/tools/dynamo/verify_dynamo.py#L46

According to this document, I think it is OK to set it to oem or ansi. I think "oem" is for supporting older hardware.
https://docs.python.org/zh-cn/3/library/codecs.html#text-encodings

### Versions

```
Collecting environment information...
PyTorch version: 2.5.1+cu124
Is debug build: False
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 11 专业版 (10.0.22631 64 位)
GCC version: (x86_64-win32-seh-rev0, Built by MinGW-Builds project) 14.2.0
Clang version: Could not collect
CMake version: version 3.30.5
Libc version: N/A

Python version: 3.12.7 | packaged by Anaconda, Inc. | (main, Oct  4 2024, 13:17:27) [MSC v.1929 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-11-10.0.22631-SP0
Is CUDA available: False
CUDA runtime version: 12.6.77
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Name: 12th Gen Intel(R) Core(TM) i5-12500H
Manufacturer: GenuineIntel
Family: 205
Architecture: 9
ProcessorType: 3
DeviceID: CPU0
CurrentClockSpeed: 2500
MaxClockSpeed: 2500
L2CacheSize: 9216
L2CacheSpeed: None
Revision: None

Versions of relevant libraries:
[pip3] lion-pytorch==0.2.2
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.3
[pip3] nvidia-cuda-runtime-cu12==12.6.77
[pip3] onnx==1.17.0
[pip3] onnxruntime-gpu==1.20.1
[pip3] onnxscript==0.1.0.dev20241102
[pip3] onnxsim==0.4.36
[pip3] torch==2.5.1+cu124
[pip3] torch_tensorrt==2.5.0
[pip3] torchaudio==2.5.1+cu124
[pip3] torchinfo==1.8.0
[pip3] torchvision==0.20.1+cu124
[pip3] triton==3.1.0
[conda] lion-pytorch              0.2.2                    pypi_0    pypi
[conda] numpy                     1.26.3                   pypi_0    pypi
[conda] nvidia-cuda-runtime-cu12  12.6.77                  pypi_0    pypi
[conda] torch                     2.5.1+cu124              pypi_0    pypi
[conda] torch-tensorrt            2.5.0                    pypi_0    pypi
[conda] torchaudio                2.5.1+cu124              pypi_0    pypi
[conda] torchinfo                 1.8.0                    pypi_0    pypi
[conda] torchvision               0.20.1+cu124             pypi_0    pypi
[conda] triton                    3.1.0                    pypi_0    pypi
```

cc @peterjc123 @mszhanyi @skyline75489 @nbcsm @iremyux @Blackhex @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @aakhundov