Hello,
System Specs: Ubuntu 23.04 Gnome 44.0 Geany 1.38
I wanted to look through some system log file from /var/log.
I copied syslog to my $HOME directory then I ran chown foo:users syslog.txt on it, to make sure I owned the file and could open and read it as a user. I also changed the permissons on it; chmod 0644 syslog.txt
When I try and click on it with Geany, it comes up empty and also says at the top ```untitled Geany```.
I can open the file and view it just fine with nano.
I don't understand why this file doesn't open and appears empty when I try to view it?
The file size is possibly large in size, it's 63mb in size, but I am not aware that Geany has any size restrictions like this.
GitHub only allows 25mb, so I uploaded it here;
https://uploadnow.io/f/SHVx1KH
I don't understand why this file doesn't open and appears empty when I try to view it?
It appears empty because it does not open, and so the default empty file is shown, look at the status bar message.
There is something weird about the file contents that makes it fail all known encodings, if you force the encoding to utf-8 it opens.
I personally run Slackware, but I decided to do a little distro hopping and play around again, so I just installed Ubuntu 23.04.
I assumed the contents of syslog on any distro is the same, because in Slackware, I've never had any issues like this before.
When I installed geany in Slackware I compiled it from source, and I never changed any of these settings. Does geany by default use a standard encoding setting?
In Ubuntu it is on Western (ISO-88591) so I wonder if in Slack, if might of been on UTF-8... hmm
Forgive my ignornance, but I thought in the West 88591 is the standard to open any file?
THANKS
Forgive my ignornance, but I thought in the West 88591 is the standard to open any file?
No.
The process in Geany (IIRC, didn't refresh my memory, but its roughly right) is:
1. if the encoding is forced (the setting in "more options" in the open dialog), use that and succeed or fail, don't try anything else 2. check for BOMs and use that (if UTF-8 just validate, don't convert) 3. try the default from the setting you show above, ie UTF-8 and validate 4. look for encoding message in file (some common things like HTML `charset=`, or editor `coding: `), try that 5. try every encoding in the list in some order, first with no error wins
Something about the file makes it fail when trying encodings, but it does succeed when forced (for me). It may be something in the exact way the Glib convert is called in the various cases.
I'm not a programmer, I just use geany for some real basic stuff, so a lot of this is flying over my head.
2. check for BOMs and use that (if UTF-8 just validate, don't convert) - I have no idea what this means, or how to do?
The only message I get in geany is;
syslog does not look like a text file or the file encoding is not supported.
So for any steps you'd like me to try, please help and be specific how I can accomplish them like BOM?
THANKS
I just tried all the releveant encodings for English in the first option for a new file. I didn't bother with Asian or Middle Eastern, etc...
Notthing works, and I find this odd, that I can't get geany, in the Preferences section to open a file.
Geany documents (in memory, not files on disk) are UTF-8 so on opening a file has to be converted to UTF-8 if it isn't already. The list above is the process Geany uses to try to do this. Its not simple, encodings __cannot__ be uniquely determined from file contents, so the process above is attempted.
Encodings are evil hangovers from a pre-Unicode past and should be burned with fire. There is no way to tell what encoding has been used on a file, if I write a file with my locale encoding it may fail to open with your locale if its different, or it might open with different characters. _Use Unicode!!!!_ [end rant at the world in general]
The only message I get in geany is; syslog does not look like a text file or the file encoding is not supported.
As it says, all encodings known to Geany failed to convert to utf-8 without errors, see item 5. on my list.
Encoding conversion libraries are system provided libraries, not part of Geany, and they do not provide brilliant error indications, neither where nor what went wrong. So there is no information about what the encoding conversion doesn't like about your file.
BOM
https://en.wikipedia.org/wiki/Byte_order_mark
To be clear, the file opened for me if I forced UTF-8 on the open dialog by setting it in the "More Options->Set Encoding:" from "Detect from file" to "UTF-8". Don't forget to set it back to detect afterwards!.
Just to emphasise, its not in preferences or the menus, its on the open dialog.
As I mentioned I did all the encodings relevant for English, nothing works.
BOM, I will look into that.
I do not have; "More Options->Set Encoding:" from "Detect from file" to "UTF-8"
Where are you seeing this at?
THANKS
On the open dialog, at the bottom, on the opposite side from the `view` `cancel` `open` buttons.
AHHH LOL, my bad, sheesh...
Ok, so then in the Preferences when I set the encoding to UTF-8 shouldn't this also work?
```On a side note, can the 'Recent Files' be disabled in geany?```
THANKS
when I set the encoding to UTF-8 shouldn't this also work?
If the file is a perfectly complying UTF-8 yes, but IIRC setting the force option on the open dialog also minimises the checking to maximise the chances of the file opening, for Geany it must convert to UTF-8 but doesn't need to meet all the Unicode rules for "validity". See wikipedia about UTF-8 validation and illegal values, maybe your file has one of those.
Geany tries its best to handle various encodings, but in the end its not an encoding converter, its a program text editor and program text is ... well text, so Unicode. There are specific applications that handle encoding conversions and handling.
AFAIR recent files can't be disabled, why?
Ok on UTF-8
I don't see any options to disable Recent Files history, or to clear it, the only way I see is to remove the entries manually on the config file... hmm
THANKS
Well, you can set the MRU list length to zero `Edit->Preferences->Files->Miscellaneous->Recent files list length`. It requires a Geany restart to apply.
But I still want to know what your use-case is?
Sorry my bad I overlooked this setting, this worked, thanks.
```use-case?```
use-case?
"A usage scenario for a piece of software" - https://en.wikipedia.org/wiki/Use_case
Regarding the file open issue: it's not about encodings in this case but the file contains NULL bytes and Geany does not support that.
See also https://github.com/geany/geany/issues/1508 which has even more references to issues like this.
To answer the probably upcoming question when it will possible: it might be possible to implement this but it's not as trivial as it may sound and as long as nobody has a persistent interesting in developing this feature, it's unlikely it will happen.
To give something constructive: as a workaround you can replace the NULL bytes in the file and then it can be opened easily in Geany. `tr '\0' '_0_' < syslog.txt > syslog_nonull.txt`
Regarding the file open issue: it's not about encodings in this case but the file contains NULL bytes and Geany does not support that.
@eht16 so why does it open (with no errors) when the encoding is forced on the open dialog?
Maybe it should. Here, the file is opened without an error if I force "Without encoding". This is probably because the encoding detection code is not used then and so won't fail on NULL bytes.
But the file is *not* opened without errors because in Geany, it is loaded until the first NULL byte and then cut off.
I agree this should be better and an error or at least information shown to user.
Here, the file is opened without an error if I force "Without encoding".
And if I force UTF-8.
But the file is not opened without errors because in Geany, it is loaded until the first NULL byte and then cut off.
I agree this should be better and an error or at least information shown to user.
Yes, sorry not to be clear, by "no errors" I meant no error messages. I thought there was a message about file "might be truncated" or similar when a null was detected.
github-comments@lists.geany.org