Version: (using KDE 4.2.1) OS: Linux Installed from: Ubuntu Packages The default encoding for text files is UTF-8, however I'd like to open legacy PHP files with ISO-8859-2 encoding. Kate is set to: Default encoding: UTF-8 Encoding detection: Off or Central European (doesn't matter) Under "Modes & Filetypes" the following variables are set for "Scripts/PHP (HTML)": kate: replace-tabs false; tab-width 3; indent-width 3; encoding iso-8859-2; When I open a PHP file for the first time, it's open readonly as UTF-8 and a message about invalid characters is shown. I need to close the file and open it again for that modeline to take effect.
Same here (Kate 3.2.3, KDE 4.2.3, Kubuntu 9.04). I have set up a new filetype (Markup/TTX) for some special UTF-16 XML files (*.TTX, TRADOSTag documents). The "Variables" field says: kate: encoding UTF-16; When I open such a file (by clicking on it in Dolphin, or by drag-and-drop in the Kate window), it always opens first in the default UTF-8 encoding, and I have to reopen or reload it (F5) in order to convince it to open in UTF-16.
I guess Kate needs some sort of automatic encoding choosing when opening a file through the file browser, command line or using a file picker with "Encoding" set to "automatic". Using this "automatic" setting, Kate could choose the right encoding using the following criteria: - check the file modeline, - check the directory .kateconfig, - check Kate configuration, - use system-wide encoding through environment variables.
Reading the file's modeline before knowing its encoding is actually impossible. Check .kateconfig and the Mode makes sense. Via const KateFileType& KateModeManager::fileType(const QString &name) const; we can get the KateFileType and then the value for "encoding" (needs an additional query function). But this still does not check the .kateconfig. The other way is, as soon as the encoding is known, reload the document again with the right encoding (if it was wrong).
*** Bug 135581 has been marked as a duplicate of this bug. ***
related bug for .kateconfig file: bug #125974
related bug for modes/filetypes: bug #159135
I had exactly the same behaviour as Piotr in the beginning. After some experiments I now have a new effect: - After opening a file, the "Extras" menu now claims the encoding is "Unicode > utf7" (no typo, it's really utf_7_) - BUT iso umlauts are a) displayed correctly and b) remain correct even after adding new umlauts & saving & reopening the file. So it seems "katepart" somehow internally is actually now using the correct encoding but "kate" thinks it's utf7. Also no complains about wrong character codes when opening these files. File type definition variables: "kate: encoding iso-8859-1;" Other settings: - Open/Save common: Encoding "ISO 8859-1", autodetect off.
(In reply to comment #7) About: Kate Version 3.3.5 Unter KDE 4.3.5 (KDE 4.3.5) "release 0" Kate-Komponente Version 3.3 Unter KDE 4.3.5 (KDE 4.3.5) "release 0"
Git commit bd03d9a8302b9c98a7cf1aa389ea9e55c25d2db3 by Christoph Cullmann. Committed on 25/06/2011 at 11:43. Pushed by cullmann into branch 'master'. no encoding: xxx variable support it never worked, it cant work given the fact we eval all vars only after load sorry, but the fixed encoding detection in KDE 4.5/.6 must be enough BUG: 187033 M +1 -7 doc/kate/configuring.docbook M +0 -2 part/document/katedocument.cpp http://commits.kde.org/kate/bd03d9a8302b9c98a7cf1aa389ea9e55c25d2db3