visual-studio 使用 Visual Studio 在源代码中显示日文字体

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/210547/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 09:46:59  来源:igfitidea点击:

Displaying Japanese fonts in source code using Visual Studio

visual-studio

提问by Ben Lever

I have some source files that have comments written in Japanese. When I open these files in Visual Studio they appear like this:

我有一些带有日文注释的源文件。当我在 Visual Studio 中打开这些文件时,它们显示如下:

à–?FNCAP‰1—p?ì?X???b?h

I am using the English version of WinXP, but is there a way to get Visual Studio to display the actual Japanese characters rather than the random jibberish it currently is?

我使用的是英文版的 WinXP,但是有没有办法让 Visual Studio 显示实际的日文字符而不是当前的随机乱码?

采纳答案by puzio

Presumably VS is interpreting the file with the wrong encoding.

大概 VS 正在用错误的编码解释文件。

Reopen it using "File -> Open -> File... -> Open -> Open With... -> Source Code (Text) Editor With Encoding" and try various encodings.

使用“文件 -> 打开 -> 文件... -> 打开 -> 打开方式... -> 带有编码的源代码(文本)编辑器”重新打开它并尝试各种编码。

回答by puzio

I found a general solution to the problem. This worked for me in Chinese text for Visual Studio 2013 and Windows 8.1.

我找到了这个问题的通用解决方案。这在 Visual Studio 2013 和 Windows 8.1 的中文文本中对我有用。

per https://msdn.microsoft.com/en-us/library/ms246590.aspx

每个https://msdn.microsoft.com/en-us/library/ms246590.aspx

  1. As Administrator Click Start, click Control Panel, and then open Regional and Language Options (or Region in Windows 8).
  2. Click the Advanced tab. (or Administrative in Windows 8)
  3. In the Select a language to match the language version of the non-Unicode programs you want to use list, select the language you are currently using.
  4. Click OK.
  1. 以管理员身份单击开始,单击控制面板,然后打开区域和语言选项(或 Windows 8 中的区域)。
  2. 单击高级选项卡。(或 Windows 8 中的管理)
  3. 在“选择一种语言以匹配您要使用的非 Unicode 程序的语言版本”列表中,选择您当前使用的语言。
  4. 单击确定。

回答by ryan_s

Have you turned on support for Eastern languages for Windows? I have that turned on and I can see Chinese characters in Visual Studio 2005 on WinXP.

您是否为 Windows 开启了对东方语言的支持?我已经打开了,我可以在 WinXP 上的 Visual Studio 2005 中看到中文字符。

To turn it on you'll probably need the installation DVD for Windows. The setting is under Regional and Language Options in the Control Panel. I think you just need to check the "Install files for East Asian languages" option.

要打开它,您可能需要 Windows 的安装 DVD。该设置位于控制面板中的区域和语言选项下。我认为您只需要选中“为东亚语言安装文件”选项即可。

Microsoft's support page for internationalizationhas some screenshots and instructions.

Microsoft 的国际化支持页面有一些屏幕截图和说明。

回答by DubiousPusher

I faced the same issue and have found a solution that works for me.

我遇到了同样的问题,并找到了适合我的解决方案。

The problem is that the files aren't unicode and VS is trying to open them with an encoding that matches your location. Luckily, you can set Windows default behavior for non-unicode files. Check out this link, http://msdn.microsoft.com/en-us/library/ms246590.aspx. Look under "To correctly display characters that are not included in the current code page."

问题是这些文件不是 unicode 并且 VS 正在尝试使用与您的位置匹配的编码打开它们。幸运的是,您可以为非 unicode 文件设置 Windows 默认行为。查看此链接,http://msdn.microsoft.com/en-us/library/ms246590.aspx。查看“正确显示当前代码页中未包含的字符”。

These directions are incorrect for Windows 8 (I can't speak for 7 or older.) For Windows 8:

这些说明对于 Windows 8 是不正确的(我不能说 7 或更旧的版本。)对于 Windows 8:

  1. Navigate to Control Panel
  2. Select Clock, Language, and Region (yeah they still have the comma before and)
  3. Region
  4. Administrative
  5. Change System Locale...
  6. Select the desired language from the "Current System Locale" drop down
  1. 导航到控制面板
  2. 选择时钟、语言和区域(是的,它们前面还有逗号)
  3. 地区
  4. 行政的
  5. 更改系统区域设置...
  6. 从“当前系统区域设置”下拉菜单中选择所需的语言

Most of your programs should continue to function in English as this setting is only applied when programs and files don't support unicode.

您的大多数程序应继续以英语运行,因为此设置仅在程序和文件不支持 unicode 时应用。

回答by VoHinh

i have just gotten this problem and fixed it by changing config "files.encoding" in file "setting.json" . Go to Menu => File => Reference => setting to open the file. Search for "files.encoding" and change value to Encoding of your file (my file encoded in Shift-JIS , i checked ending by using Notpad++)

我刚刚遇到了这个问题,并通过更改文件“setting.json”中的配置“files.encoding”来修复它。转到菜单 => 文件 => 参考 => 设置以打开文件。搜索“files.encoding”并将值更改为文件的编码(我的文件以 Shift-JIS 编码,我使用 Notpad++ 检查了结尾)

回答by maithanhduyan

Windows 10 : --> Control Panel\Clock and Region\Region

Windows 10 : --> 控制面板\时钟和区域\区域

enter image description hereenter image description here

在此处输入图片说明在此处输入图片说明

回答by Major Murphy

You can also convert the text encoding to UTF-8 using Notepad++.

您还可以使用 Notepad++ 将文本编码转换为 UTF-8。

  1. Originally encoded as Shift-JIS:

    image1

  2. Convert to UTF-8:

    image2

  3. Save file.
  1. 最初编码为 Shift-JIS:

    图片1

  2. 转换为 UTF-8:

    图像2

  3. 保存存档。

It should now display correctly regardless of local region.

无论本地区域如何,它现在都应该正确显示。