Restore support for Latin1 file names on openSUSE Leap 16
While openSUSE Leap 15.3 (and maybe also later 15.x versions) was still based
on Qt5, and therefore had no problem supporting file names encoded in iso8859-1
(a.k.a. Latin1) or even other single byte character sets, Leap 16.0 switched to
Qt6, which now enforces the use of "UTF-8 everywhere".
I try to use 7-bit ASCII wherever possible, so I write everything in English,
which saves me from all the trouble with character sets. However, since my native
language is German, there are occasions where I like/need to name a file or
directory with German umlauts (like "München"), and I don't want to have them
encoded in UTF-8. Plain old iso8859-1 is fully sufficient for me.
Let's not even get into the hoops you have to jump through in Perl just to deal with UTF-8.
Thankfully the important functions to convert from Qt's internal character representation
(which is UTF-16) to the underlying file system's character set (which can be
UTF-8, but may as well be iso8859-1 or any other single byte set) are still there,
so patching Qt6 is pretty straightforward.
Unfortunately Qt6 has apparently removed all but Latin1 character sets, but at
least for my purposes this is sufficient.
Download
GIT archive
The official GIT archive is hosted at
https://git.tvdr.de
Use the command
git clone --branch stable/latest git://git.tvdr.de/suse-leap-latin1.git
to clone the archive and check out the latest stable version.
ZIP archive
The source code for the latest version can be downloaded from
https://git.tvdr.de/?p=suse-leap-latin1.git;a=snapshot;h=stable/latest;sf=zip
The patch
This patch modifies three source files of Qt6:
- qstring.cpp
to make the conversion between Qt's internal UTF-16 characters respect the character
set selected in the LC_CTYPE environment variable. This applies only to character sets
ending in "8859-1", as in, for instance, "de_DE.iso8859-1". If LC_CTYPE is undefined
or contains anything else, the default behavior is retained (which means UTF-8).
- qcoreapplication.cpp
to prevent Qt from overwriting the locale with UTF-8 if it has been set to iso8859-1
by the user. It is also here where command line arguments that are not valid UTF-8
strings are converted to UTF-16 by a call to QString::fromLocal8Bit() instead of the
default QString::fromUtf8().
- qprocess.cpp
for implementing a workaround for working directories that contain non-ASCII characters
on a Latin1 system. In such cases the process isn't even started. The problem is
presumably somewhere in KIO, and occurs, for instance, if Dolphin is currently showing
a directory with some German umlaut character (like "München") and you select "Open
with Gewenview" on an image file in that directory. Without this workaround the
command is silently ignored, maybe because KIO tries to access the working directory
and doesn't honor the setting of LC_CTYPE.
Usage
The script file suse-leap-latin1-build that comes with this patch does all the
work necessary to build a patched version of the Qt6 library file libQt6Core.so.6.9.1.
You may want to run this on a fresh installation of openSUSE Leap 16.0,
preferably on a virtual machine (to not pollute your system with software
packages you won't need later). Make sure your VM has at least 16GB of RAM,
otherwise the build process may run out of memory.
Copy the files
suse-leap-latin1-build
0002-Restore-Latin1-for-file-names.patch
into a new directory. Change into that directory and execute the script.
When prompted for decisions type either 'y' (yes) or 'n' (no) and hit enter.
If the script finishes successfully there should be a file named
libQt6Core.so.6.9.1, which replaces the original file in /usr/lib64.
After replacing the library file you should reboot your system.
Enable Latin1 support
To enable Latin1 support you should do the following:
- In /etc/sysconfig/console add
CONSOLE_ENCODING="iso8859-1"
- In /etc/sysconfig/language set
RC_LC_CTYPE="en_US.iso8859-1"
- In .bashrc (or whichever file your shell reads) make sure you set the command
line prompt via PROMPT_COMMAND, and not by directly setting PS1,
This makes sure umlauts in the current directory are displayed correctly, and not
as "M-v".
Applications
All applications that are linked dynamically to Qt6 will support Latin1 in file
and directory names with this patch.
Nevertheless, some fine tuning may be necessary if you also want to use Latin1
in text files and show these characters correctly in the Konsole.
Here is a list of some of the applications that I use, how to set them up properly,
and what works or doesn't work with umlauts in file names:
Qt Applications
- Dolphin
Works.
- Gwenview
Works.
- Kate
Settings/Configure Kate/Open/Save/General/Encoding: Western European (ISO 8859-15).
- Konsole
Settings/Configure Konsole.../Profiles/<profile name>/Edit/Advanced/Default character encoding: Western European/ISO 8859-1.
Non Qt Applications
- Firefox
Displays file names wrong, but loads files correctly.
- Gimp
Works when called directly.
Fails to load the selected file when called via "Open with...".
- LibreOffice
Works when called from command line.
Fails to load the selected file when called via "Open with...".
to be continued...
TODO
The workaround in qprocess.cpp could perhaps be avoided if KIO was also patched to behave
properly in a Latin1 environment.
Links
openSUSE
GIT for qt6-base
My other projects
VDR - The Video Disk Recorder
Full Motion Flight Simulator
GeoTagger - Display and modify GPS location data in photos
Interface zur Verbindung einer digitalSTROM-Klemme GR-KL200 mit einem VELUX KLF 050x
Monitoring the Bluetti AC300 Power Supply
Impressum