[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: View Latin1 encoded file in a terminal with LANG set to de_DE.UTF-8
From: |
Benno Schulenberg |
Subject: |
Re: View Latin1 encoded file in a terminal with LANG set to de_DE.UTF-8 |
Date: |
Fri, 20 Sep 2024 17:42:15 +0200 |
User-agent: |
Mozilla Thunderbird |
Op 20-09-2024 om 14:20 schreef Joachim Breit:
I have a file encoded in Latin-1 (cp1252). When I open this file with Nano
(from a terminal window in KDE) lots of characters are not displayed
correctly), presumably because my system is set to UTF-8 (environment
variable LANG=de_DE.UTF-8). The Nano menus are displayed fine.
My first idea was to do a 'export LANG=de_DE@euro' before starting Nano. But
then both the nano menus and the file are showing placeholder characters for
German Umlaute an Spanish accents.
When wanting to edit a file in a different encoding, the easiest
solution is to convert the file to UTF-8 first. In your case:
iconv -f cp1252 -t utf8 <yourfile >editablefile
After editing, you can convert the file back, if needed.
If conversion is not an option, then you must set not only the
shell environment to the relevant locale, but you must also tell
the terminal what encoding to use. For Konsole, that should be
somewhere in the Settings, probably the Advanced tab, Encoding,
West-European, and then ISO-8859-1. After that close and restart
the terminal. Then `export LANG=de_DE.iso88591`, and accented
characters should be shown properly. (Don't forget to switch
the encoding of the terminal back afterwards.)
Benno
OpenPGP_signature.asc
Description: OpenPGP digital signature