Embarcadero / Dev-Cpp

A fast, portable, simple, and free C/C++ IDE
https://www.embarcadero.com/free-tools/dev-cpp
GNU General Public License v2.0
2.52k stars 276 forks source link

The problem about file encoding #81

Open Dian-Jiao opened 3 years ago

Dian-Jiao commented 3 years ago

example.zip

  1. Cannot open ANSI files containing Chinese characters. ( See example1.cpp please. ) error error2 2.It can open UTF-8 files containing Chinese characters, but it can't display the Chinese characters when the cursor is not on the same line as the Chinese character. ( See example2.cpp please. )

These problems didn't happened in 5.11 ( Though 5.11 sometimes are not displayed some Chinese characters completely when the cursor is not on the same line as the Chinese character, but 6.x almost isn't displayed all Chinese characters. )

FMXExpress commented 3 years ago

5.11 is built with Delphi 7 and doesn't support Unicode at all. It uses ANSI and the codepage of your version of Windows. If I were to open an ANSI file with Chinese characters from a Chinese codepage version of Windows it would not show those characters on my version of Windows which uses codepage 1252.

How did you try to open the file? By default the 5.11 TSynEdit is ANSI. By default the 6.2 TSynEdit is UTF8. But there is a new setting in the 6.2 editor options that let's you default the TSynEdit to ANSI. And you can select ANSI when you open a file.

We should get the default settings aligned so they just work for Chinese characters though.

The second bug you mention is already here https://github.com/Embarcadero/Dev-Cpp/issues/63

FMXExpress commented 3 years ago

The codepage of example1.cpp is GB2312.

Dian-Jiao commented 3 years ago

The codepage of example1.cpp is GB2312.

I‘m sorry. And example1.cpp was created by 5.11...

FMXExpress commented 3 years ago

Solution is to detect the ANSI codepage and use it to load the file. Also we can have a warning dialog instead of a crash.