Why file encoding ins't autotected?

English main discussion
Post Reply
  • Author
  • Message
Offline
Posts: 61
Joined: Thu Feb 04, 2016 5:27 am

Why file encoding ins't autotected?

Post by c-sanchez »

Why akelpad don't autodetect the code page from some files?
I had noticed it previously but I had not considered it until now with a file that I wanted to modify.

I'm tried with this:
http://akelpad.sourceforge.net/forum/vi ... 7766#27766
but still not working

Check the following images
Notepad2Mod detect file encoding always
https://s6.postimg.org/nr35h3sa9/notepa ... epages.gif

But i don't know why not akelpad :(
https://s6.postimg.org/celi27d9t/akelpa ... _err01.gif


Language.dat file
https://my.pcloud.com/publink/show?code ... bICjeTxVM7

Offline
Posts: 1161
Joined: Sun Oct 20, 2013 11:44 am

Post by Skif_off »

c-sanchez
Axiom (or postulate): All programs sometimes make mistakes with encoding detection.

First file with BOM and it's not problem.

Second file haven't BOM and AkelPad uses frequency of letters, but it can be fail. For XML/HTML more correctly is read special charset attribute:
XML: encoding="encoding";
HTML: charset="encoding".
Maybe Notepad2Mod reads this attributes? I don't know.

For AkelPad you can try AutoScript-DetectEx.js (archive): add to "CmdLineBegin="

Code: Select all

/Call("Scripts::Main", 2, "AutoScript-DetectEx.js", `-DetectArray='[["xml,htm,html",".*?(encoding|charset)=([a-z\\d_\\-]+)","i","$2",-1,-2]]'`)
XML markup language is popular, you can add extensions, with which you often deal.

Offline
Posts: 61
Joined: Thu Feb 04, 2016 5:27 am

Post by c-sanchez »

Thanks for you reply Skif_off.

The first file on image was created on AkelPad, sorry I forgot to mention it before, although well, I created two UTF-8 test files on Notepad3 And they work on AkelPad too.

The trick with AutoScript-DetectEx.js and "CmdLineBegin=" doesn't works. Maybe i did something bad?

Anyway, then maybe the way from Notepad2, Notepad3 (and i guess all scintilla based) is better?
On this case i think maybe AkelPad need to be improved on this aspect.

Offline
Posts: 1161
Joined: Sun Oct 20, 2013 11:44 am

Post by Skif_off »

c-sanchez wrote:The first file on image was created on AkelPad, sorry I forgot to mention it before
It does not matter.
c-sanchez wrote:Anyway, then maybe the way from Notepad2, Notepad3 (and i guess all scintilla based) is better?
It's heresy! :))) AFAIK, Scintilla (as component) is not engaged in encoding/decoding, it makes the program itself. And Notepad3 has some problem with insert clipboard.
And:
Skif_off wrote:Axiom (or postulate): All programs sometimes make mistakes with encoding detection.
I use recognition buffer=8192 and I have problems rarely happen (usually it's XML-based files and HTML-pages).
c-sanchez wrote:The trick with AutoScript-DetectEx.js and "CmdLineBegin=" doesn't works. Maybe i did something bad?
Show your string for CmdLineBegin= and file name. Script works only with the specified extensions, in my example with *.xml, *.htm, *.html, but for Language.dat you must add "dat":

Code: Select all

/Call("Scripts::Main", 2, "AutoScript-DetectEx.js", `-DetectArray='[["xml,htm,html,dat",".*?(encoding|charset)=([a-z\\d_\\-]+)","i","$2",-1,-2]]'`)
c-sanchez wrote:On this case i think maybe AkelPad need to be improved on this aspect.
AutoScript-DetectEx.js was created to do just that.

Offline
Posts: 1161
Joined: Sun Oct 20, 2013 11:44 am

Post by Skif_off »

Hmm... Which version are you using? 4.9.8/4.9.9 dev correctly opened as UTF-8 without BOM without AutoScript-DetectEx.js (but this script is still useful and can be useful).

WinXP Rus + AkelPad Eng and changed settings: https://s13.postimg.org/f6wid3pbr/image.png (I think as your)

Offline
Posts: 61
Joined: Thu Feb 04, 2016 5:27 am

Post by c-sanchez »

Skif_off wrote:Show your string for CmdLineBegin= and file name. Script works only with the specified extensions, in my example with *.xml, *.htm, *.html, but for Language.dat you must add "dat":
haha i'm sorry, was my fault, I've ignored the -DetectArray= option :P
This is working :)

also..
Skif_off wrote:I use recognition buffer=8192 and I have problems rarely happen (usually it's XML-based files and HTML-pages).
I'm sorry one more time, was (again) my fault.
Before to do the topic I had tried changing the buffer to 8192, But it had not worked, UNTIL NOW, because I forgot UNCHECK the Remember code page option :lol:

So yeah, works properly with buffer=8192 or using AutoScript-DetectEx.js :)
Skif_off wrote:Hmm... Which version are you using? 4.9.8/4.9.9 dev correctly opened as UTF-8 without BOM without AutoScript-DetectEx.js (but this script is still useful and can be useful).
I'm using 4.9.8. Now i have the doubt, where i can check the dev builds?
About my settings, is nothing special, just now the buffer on 8192 heh.
https://s6.postimg.org/kgkcl9241/akelpad_0002112.png

Thank you very much for your help Skif_off, It is appreciated :)

Offline
Posts: 1161
Joined: Sun Oct 20, 2013 11:44 am

Post by Skif_off »

c-sanchez wrote:where i can check the dev builds?
Instructor writes and gives a direct link to file when something adds or fixes. Watch the news :)
Files are here (+ x64 now). Current (from repository) AkelHistory-Eng.txt, but I'm not sure that is ALL changes (if I'm not mistaken, even some bugs was fixed in 4.9.8 dev).

Offline
Posts: 61
Joined: Thu Feb 04, 2016 5:27 am

Post by c-sanchez »

From time to time I check the Forum news, but until now I had seen nothing of these versions :P maybe is on Russian Discussions? :?:
Anyway thanks for the links, for now I'm fine with the stable version :)

To don't make more topics i think is better leave here my simple doubts, right? So

I'm trying add the Minimize / Restore / Exit buttons on Toolbar, so i have the following lines

"Minimize AkelPad" Command(????) Icon("%a\AkelFiles\Icons\minimize.ico", 0)
"Restore/Maximize Window" Command(4331) Icon("%a\AkelFiles\Icons\restore.ico", 0)
"Exit from AkelPad" Command(4109) Icon("%a\AkelFiles\Icons\exit.ico", 0)

Image

Then we have AkelPad internal commands 4331 (Restore/Maximize main window) and 4109 (Exit program) but i can't see any command for minimize window, maybe using Keyboard commands, like Alt+F4? Although I guess the best would be a Internal command for this.

After achieving this I want (if possible) remove/hide the window tittle bar and then make the window draggable from toolbar and free tabs space

---

Another doubt about AkelPad settings.

Is possible add custom entries on default AkelPad Main Menu entries (File, Edit View, Optios, Window, Help) and sub-menus?
By example, i wonder if i can add something like this: File > Recent files > Clear recent files

Offline
Posts: 61
Joined: Thu Feb 04, 2016 5:27 am

Post by c-sanchez »

c-sanchez wrote:Is possible add custom entries on default AkelPad Main Menu entries (File, Edit View, Optios, Window, Help) and sub-menus?
By example, i wonder if i can add something like this: File > Recent files > Clear recent files
Ok, i found this Link
Usefull, but i'm noticed Recent files plugin don't have option to clear all recent files, just DeleteNonExistent
While AkelPad have the option to Clear all recent files on Settings > Registry.
AkelPad as internal command just have 5001 too, ie Delete dead recent files from "Recent files" list
Some way to call the option to Clear recent files? and so set the option on Context Menu.
Post Reply