Bug 445015

Summary: Unsuccessful "View in another encoding" is remembered by Kate after reopening the file
Product: [Applications] kate Reporter: soshial <soshial>
Component: encodingAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: thomas.surrel
Priority: NOR    
Version First Reported In: 21.12.0   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Step 1: open the file (encoded in cp1251)
Step 2: switch to Unicode
Step 3: Kate returns error after switch to Unicode
Step 4: close Kate and reopen the file
A plain-text file in cp1251 encoding for testing.

Description soshial 2021-11-05 12:38:48 UTC
Created attachment 143238 [details]
Step 1: open the file (encoded in cp1251)

SUMMARY
After unsuccessful "View in another encoding" file is re-opened 

STEPS TO REPRODUCE
1. Open a non-Unicode file (for example, Cyrillic encoding CP1251)
2. Choose "View as Unicode -> UTF8". Result: you see an error, the text is garbled and file becomes read-only in the editor
3. Close Kate and reopen the file.

OBSERVED RESULT
File wasn't changed and the text looks correct (not garbled). But Kate shows that the file encoding is now UTF8.

EXPECTED RESULT
Since the "View in UTF8 encoding" action resulted in error, the encoding should be cp1251 (as initially it was).

SOFTWARE/OS VERSIONS:
Operating System: Manjaro Linux
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2
Kernel Version: 5.15.0-1-MANJARO (64-bit)
Graphics Platform: X11
Comment 1 soshial 2021-11-05 12:39:23 UTC
Created attachment 143239 [details]
Step 2: switch to Unicode
Comment 2 soshial 2021-11-05 12:40:01 UTC
Created attachment 143240 [details]
Step 3: Kate returns error after switch to Unicode
Comment 3 soshial 2021-11-05 12:40:20 UTC
Created attachment 143241 [details]
Step 4: close Kate and reopen the file
Comment 4 Thomas Surrel 2021-12-22 12:09:14 UTC
Hi ! Could you attach an cp1251 encoded example ?
Comment 5 soshial 2021-12-23 09:08:09 UTC
Created attachment 144796 [details]
A plain-text file in cp1251 encoding for testing.

Here's the test cp1251 file. It weighs 40 KiB.

If it is converted to UTF8, it should become 54 KiB.
Comment 6 Christoph Cullmann 2024-06-15 17:42:30 UTC
Git commit 7f6152b3b0a06469a31bce9b58f3354b481b4542 by Christoph Cullmann.
Committed on 15/06/2024 at 17:42.
Pushed by cullmann into branch 'master'.

don't remember encoding if known to be broken

M  +2    -2    src/document/katedocument.cpp

https://invent.kde.org/frameworks/ktexteditor/-/commit/7f6152b3b0a06469a31bce9b58f3354b481b4542