Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty file with non-Unicode encoding cannot be saved #10699

Closed
KiBERMiKE opened this issue Oct 20, 2021 · 4 comments · Fixed by #10702
Closed

Empty file with non-Unicode encoding cannot be saved #10699

KiBERMiKE opened this issue Oct 20, 2021 · 4 comments · Fixed by #10702

Comments

@KiBERMiKE
Copy link

KiBERMiKE commented Oct 20, 2021

Notepad++ v8.1.8
If the opened file is encoded Windows-1251 and we delete all text and do "Save", then the changes are not saved

Steps to Reproduce the Issue

  1. Open file in Windows-1251
  2. Delete all text
  3. Save
  4. Close Notepad++
  5. Open this file again
@Yaron10
Copy link

Yaron10 commented Oct 21, 2021

The problem exists with other encodings as well (e.g. Windows-1255).

STR:
Open a UTF-8 document.
Change the encoding to Windows-1255.
Delete all.
Save.

Result:
The file contains the content prior to the deleting.

@donho,
Could you please look into that?

Thank you.

@donho donho self-assigned this Oct 21, 2021
@donho
Copy link
Member

donho commented Oct 21, 2021

Damned! How come I didn't see it coming.
Thank you @KiBERMiKE & @Yaron10
I'll fix it ASAP.

@donho donho added the accepted label Oct 21, 2021
@donho donho changed the title Edit not save Non-Unicode empty file cannot be saved Oct 21, 2021
@donho donho changed the title Non-Unicode empty file cannot be saved Empty file with non-Unicode encoding cannot be saved Oct 21, 2021
@donho
Copy link
Member

donho commented Oct 21, 2021

@Yaron10 @KiBERMiKE
Could you confirm me that #10702 has fixed this regression?

@Yaron10
Copy link

Yaron10 commented Oct 21, 2021

@donho,

👍
Great. Thank you very much.

@donho donho closed this as completed in d30b825 Oct 21, 2021
donho added a commit that referenced this issue Oct 21, 2021
The PR fixes the regression due to the saving file API being changecd from POSIX functions to Win32 native API:
The old used function "fopen" using "wbc" as argument, according Microsoft document:
"w" 	Opens an empty file for writing. If the given file exists, its contents are destroyed.
(https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-160)
so to save a 0 length document, it was unecessary to "write nothing" explicitely on disk, since fopen did it for you.
Whereas our new implementation which uses Win32 native API passes "OPEN_ALWAYS" - that needs to "write nothing" explicitely.

Fix #10699, close #10702
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants