Bug 125618 - Kate ignores the encoding specified in the File Open dialog
Summary: Kate ignores the encoding specified in the File Open dialog
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: encoding (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 179912 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-04-15 02:02 UTC by Jens Dagerbo
Modified: 2010-02-20 13:33 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Dagerbo 2006-04-15 02:02:29 UTC
Version:           2.5.2 (using KDE 3.5.2, compiled sources)
Compiler:          gcc version 3.4.3 20050110 (Gentoo Linux 3.4.3.20050110, ssp-3.4.3.20050110-0, pie-8.7.7)
OS:                Linux (i686) release 2.6.10-gentoo-r6

In Kate, when using File->Open with "iso 8859-1" specified in the dialog, to open an utf8 encoded file, it is opened as utf8. In other words: Kate overrides the user's selection.

In KWrite, the encoding selected by the user is applied.
Comment 1 Anders Lund 2006-04-15 09:43:23 UTC
Since you changed kdevelop, do you know what causes this misbehavior in kate?
Comment 2 Jens Dagerbo 2006-04-15 15:07:05 UTC
No, KDevelop had a completely different type of problem. I tried looking around in Kate to see if I understood the problem, but I quickly got lost in the architecture...
Comment 3 Adrien Cordonnier 2008-05-21 21:33:48 UTC
I can reproduce this bug with Kate 3.0.3 (KDE 4.0.3, Kubuntu package).

Yet Kate behavior seems a bit more complicated. The selected encoding from  the "open" dialog is no taken into account, instead Kate uses either:
* utf8 if the file hasn't yet been opened;
* the encoding selected to display this file last time it was open.

To reproduce the bug: save a file in iso-8859-1 (for example: « Ñïàñèáî »). Close the file. Open the file and select "cp 1251" from the dialog. The file will be displayed in iso-8859-1 even if Kate was closed in between.

The good point: Kate remember the encoding used. The bad point: it doesn't follow user's request.

Attented behavior: when a file is selected from the open dialog, the encoding should change automatically for the encoding Kate remembers. However, if the user select another encoding, his/her choice should be respected.
Comment 4 Cyrill Helg 2008-08-16 13:22:33 UTC
I'm having that issue when opening more than one file... the first file is opened with the selected encoding, but not the other files... those fallback to utf8.

Comment 5 Fabio Correa 2009-03-06 14:27:19 UTC
Another way of describing this bug is: Kate is unable to open several files with different character encodings each. Every file is opened with the same encoding as the first file opened.

I see this behaviour in kate-3.2.0 (kde-4.2.1) in Gentoo Linux.
Comment 6 Andrew Martens 2009-07-14 20:31:59 UTC
I would like to add a comment:
Kate will ignore your encoding choice if you open the file by double-clicking its name, rather than by clicking the "open" button.
Comment 7 Martin Vool 2010-01-12 23:09:22 UTC
When i edit files with KATE i use always UTF-8.
Since my native language is Estonian i use the ÖÄÜÕ/öäüõ letters.

When i open a file that contains these, then KATE show them properly(snapshot2.png) when i open another file in the same instance of KATE then it screws up the entire line of text that has these characters.(snapshot3.png)

When the first files did not contain any of these characters and the second one does then the characters are just come chinese or japanese stuff.(snapshot1.png)

When i close KATE and open up the same file(without saving any edits and the file is the first to open) then the file is all good. Sometimes closing all documents helps too.

And if i save those distored files even when not editing nowhere near the characters then the resulting files ÖÄÜÕ are broken permanently!

Screenshots here:
mardicas.mine.nu/katebug/ 

I discovered that when a file opens wrongly then seting it to ANY other encoding and then back to UTF-8 then the characters are displayed as they should(this is only when i did not edit anything yet)

Even with changing to UTF-16 (is total garbage) then back to UTF-8 and all is well..

I tied turning the autodetection on/off, baltic/universal.

And a solution is not to make it open every file as some random encoding and then set it to UTF-8.

Seems like kde (kate?) developers just don't care about this issue, even tho this probably is very easy to fix. (like i said if i change the encoding to a random value and back to UTF-8 then it displays stuff(make a f*king dirty fix to do this automatically in the background or something )

THIS IS 4 YEARS OLD ALREADY!
Comment 8 Milian Wolff 2010-01-12 23:55:26 UTC
*sigh*, if this would be so easy, why would we not have fixed it yet? Please, no need to insult us...

Could you maybe attach a file with which we could try to reproduce the problem? I do think I spotted it once or twice as well, but it was nothing reproducably. Such heisenbugs are everything but "easy" to fix.
Comment 9 Eckhart Wörner 2010-02-20 02:17:02 UTC
I managed to reliably reproduce using the following steps:

1. Create two files fileA and fileB with a non-KDE editor and some utf-8 stuff inside (make sure those filenames have never been used before)

2. Open kate

3. Go to the open dialog, select "utf-8", choose fileA: fileA is shown as utf-8 in the editor

4. Go to the open dialog, select "iso-8859-1", choose fileB: fileB is shown as iso-8859-1 in the editor

5. Close fileB, then fileA (i.e. close current file twice)

6. Go to the open dialog, select "iso-8859-1", choose fileA: fileA is shown as utf-8 in the editor (should show as iso-8859-1!)
Comment 10 Dominik Haumann 2010-02-20 12:48:58 UTC
SVN commit 1093240 by dhaumann:

Always use the encoding the user specified when opening files with the KEncodingFileDialog.

Background:
Kwrite does the following steps:
1. creates a new document
2. set the document encoding
3. open the document

Kate did the following:
1. create a new document
2. set the document encoding
3. call SessionConfigInterface::readSessionConfig on the document
   --> this read the cached encoding
4. open the document (with the wrong encoding in 3)

Now step 3 is replaced by the ParameterizedSessionConfigInterface, which reads the sessoin
config with the falg SkipEncoding.

Btw: Encoding Autodetection does nothing in the Open/Save config dialog. Anyone an idea???

BUG: 125618
CCMAIL: kwrite-devel@kde.org


 M  +26 -12    katedocmanager.cpp  
 M  +11 -5     katedocmanager.h  
 M  +12 -5     kateviewmanager.cpp  
 M  +9 -1      kateviewmanager.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1093240
Comment 11 Dominik Haumann 2010-02-20 13:21:53 UTC
*** Bug 179912 has been marked as a duplicate of this bug. ***
Comment 12 Dominik Haumann 2010-02-20 13:33:15 UTC
SVN commit 1093257 by dhaumann:

backport SVN commit 1093240 by dhaumann:

Always use the encoding the user specified when opening files with the KEncodingFileDialog.

Background:
Kwrite does the following steps:
1. creates a new document
2. set the document encoding
3. open the document

Kate did the following:
1. create a new document
2. set the document encoding
3. call SessionConfigInterface::readSessionConfig on the document
   --> this read the cached encoding
4. open the document (with the wrong encoding in 3)

Now step 3 is replaced by the ParameterizedSessionConfigInterface, which reads the sessoin
config with the falg SkipEncoding.

Btw: Encoding Autodetection does nothing in the Open/Save config dialog. Anyone an idea???

CCBUG: 125618


 M  +26 -12    katedocmanager.cpp  
 M  +11 -5     katedocmanager.h  
 M  +12 -5     kateviewmanager.cpp  
 M  +9 -1      kateviewmanager.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1093257