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: REPORTED ---    
Severity: normal CC: thomas.surrel
Priority: NOR    
Version: 21.12.0   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed In:
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.