This happens if you use an encoding where each character has two bytes.
Then CRLF will be encoded as \0\r\0\n .
Git believes this is a single-byte encoding, so it turns into \0\r\0\r\n .
This leads to the fact that the next line will go out in one byte, as a result of which every other line will be filled in by the Chinese. (since \0 becomes the low byte, not the high byte)
You can convert files to UTF8 using this LINQPad script:
const string path = @"C:\..."; foreach (var file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories)) { if (!new [] { ".html", ".js"}.Contains(Path.GetExtension(file))) continue; File.WriteAllText(file, String.Join("\r\n", File.ReadAllLines(file)), new UTF8Encoding(encoderShouldEmitUTF8Identifier: true)); file.Dump(); }
This will not fix broken files; you can fix files by replacing \r\n with \n in a hex editor. I do not have a LINQPad script. (since there is no simple Replace() method for byte[] s)
SLaks source share