Linux 从“转换文件类型”;UTF-8 Unicode文本“;至;C来源,ISO-8859文本“;

Linux 从“转换文件类型”;UTF-8 Unicode文本“;至;C来源,ISO-8859文本“;,linux,windows,utf-8,touch,iso-8859-15,Linux,Windows,Utf 8,Touch,Iso 8859 15,我是一名程序员。我使用GCC在Linux中编写C代码,它们可以正确运行。现在,我想使用Visual studio 2015在Windows系统中运行这些代码。但它总是显示一些错误和警告,如下所示: 1>f:\md\test_sm3_hmac_02\tools.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the

我是一名程序员。我使用GCC在Linux
中编写C代码,它们可以正确运行。现在,我想使用Visual studio 2015在Windows系统中运行这些代码。但它总是显示一些错误和警告,如下所示:

1>f:\md\test_sm3_hmac_02\tools.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>f:\md\test_sm3_hmac_02\types.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>f:\md\test_sm3_hmac_02\tools.h(13): error C2143: syntax error: missing ')' before '*'
1>f:\md\test_sm3_hmac_02\tools.h(13): error C2143: syntax error: missing '{' before '*'
当我打开每个文件并将它们复制到windows中创建的新文件中时,不做任何其他更改。它运行正常。但是我的项目包含很多文件,我这样做并不是为了解决这个问题。 我想通过做一些工作来解决它

VS2015在windows中创建的文件格式为:

$ file testtypes.h
testtypes.h: C source, ISO-8859 text
触摸屏在linux中创建的文件格式为:

$ file filetest.c
filetest.c: UTF-8 Unicode text

我该怎么办?

您可以使用
chcp 65001
将Windows代码页设置为UTF-8,这样Windows也可以读取您的UTF-8文本,以及UTF-8。Windows当前使用的是CP936,它不是ISO-8859,但很难区分两者。您试图解决错误的问题。将BOM表添加到源文件或使用编译器选项。