0

I am a programmer. I write C code in Linux using GCC, and they can run correctly. Now, I want to run these codes in Windows system using Visual studio 2015. But it always show some errors and warnings as following:

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 '*'

when I open every file and copy they in new file that is created in windows and don't do any others change. It runs correctly. But my project contains many file and I don't do this to solve this problem. I want to solve it by doing few work.

The format of file created by VS2015 in windows is:

$ file testtypes.h
testtypes.h: C source, ISO-8859 text

The format of file created by touch in linux is:

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

How can i do ?

Land
  • 171
  • 11
  • You can set the Windows code page to UTF-8 with `chcp 65001` which will make Windows read your UTF-8 text as, well, UTF-8. Windows is currently using CP936, which isn't ISO-8859, but it's hard to distinguish the two. – bk2204 Dec 07 '19 at 22:55
  • You're trying to solve the wrong problem. Either add a BOM to your source files or use the [/utf-8](https://learn.microsoft.com/en-us/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=vs-2015) compiler option. – IInspectable Dec 08 '19 at 11:35

0 Answers0