Kate confusion with NFO encoding

When I open an NFO file, it opens with Kate. That’s nice. However, with Kate 25.04.0-1 I cannot see any option to set NFO files to open with encoding CP437 (or IBM437) for correct text display on NFO files.

From a terminal, both of these lines work:

kate --encoding cp437 NFO.nfo
kate --encoding ibm437 NFO.nfo

Looking at Kate’s Settings, under the ‘Open/Save’ tab is another tab - Modes & Filetypes.

In there, we create a New filetype, but there appears to be no field to specify the encoding for this filetype… a field referenced in several searches.

I just had a go with creating a new file:

~/.local/share/org.kde.syntax-highlighting/syntax/nfo.xml

Summary
<?xml version="1.0" encoding="UTF-8"?>
<language name="NFO" version="1.0" kateversion="5.0" section="Other"
          extensions="*.nfo" mimetype="text/x-nfo" priority="1">
  <metadata>
    <property name="encoding">CP437</property>
  </metadata>
  <highlighting>
    <contexts>
      <context name="Normal" attribute="Normal Text" lineEndContext="#stay"></context>
    </contexts>
  </highlighting>
</language>

It just seems a real mess. The Manjaro ‘extra’ has a basic GTK4 viewer which similarly fails, and has no settings for encoding.

I’m tired to keep looking at this - and if I open the file in Kate it’s also no simple task (i.e. you can’t just search and find, and can’t find it by clicking…).

If you don’t need to edit the files, you might get away with adding the contents to an HTML file. A long time ago, I wrote a Python 2 script to create HTML files from .srr data. Haven’t used it in 10 years, but the end result was something like this:

<!DOCTYPE html>
<html lang="en-US">
    <head>
        <meta charset="utf-8">
        <title>something</title>
        <style type="text/css"> 
            pre { font-family: "DejaVu Sans Mono", monospace; font-size: 10px; line-height: 10px; }
        </style>
    </head>
    <body>
<pre>
<!-- stuff here -->
</pre>
    </body>
</html>

Using Python you can assemble the various things and get something similar to what those nzb sites can show you. That’s where I got the idea.

Off topic;
You must have quickly converted it from HTML(4) 10 years ago, as type isn’t required with HTML5. :slight_smile:

You can add a new association:

But I think your problem needs to be reported as bug to see how devs would respond.

1 Like

I think so, nfo already opens with Kate - but I don’t want to set Kate to launch always with CP437… only NFO.

However, not all NFO files fit the bill, so instead I wrote a script so I can pop up F4 terminal and type ‘nfo’ for kate -n --encoding ibm437 instead.

Thanks, I think it’s a regression in Kate’s settings.

Yep, what I said, haven’t used in ten years, so…