Lister: how to set UTF-8 as default view ?

English support forum

Moderators: white, Hacker, petermad, Stefan2

proof
Junior Member
Junior Member
Posts: 5
Joined: 2021-03-05, 12:56 UTC

Lister: how to set UTF-8 as default view ?

Post by *proof »

Is there a way how to make UTF-8 (option 7) default in Lister? I can see only 4 options (text / binary / hex. / auto.) in configuration dialog. I cannot find it in help / wincmd.ini either.
User avatar
Gral
Power Member
Power Member
Posts: 1467
Joined: 2005-01-26, 15:12 UTC

Re: Lister UTF-8 default view

Post by *Gral »

From TC help
Command line parameters
...
/S=L Start Lister directly, pass file name to it for viewing (requires full name including path). May include bookmark in html files, e.g. c:\test\test.html#bookmark
Accepts additional parameters separated by a colon, e.g. /S=L:AT1C1250
A ANSI/Windows text
S ASCII/DOS text
V Variable width text
T1..T8 View mode 1-8 (1: Text, 2: Binary, 3: Hex, 4: Multimedia, 5: HTML, 6: Unicode, 7: UTF-8, 8: Explorer Preview)
C<nr> Codepage, e.g. C1251 for Cyrillic
N Auto-detect, but no multimedia or plugins allowed
So, you can create button, eg. (copy code and paste on empty space on buttonbar):

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_EXE% /S=L:T7 /i=%COMMANDER_INI%
%P%N
%COMMANDER_EXE%,24
Lister UTF-8

0
-1
or user command with these settings and remap "F3" keyboard shortcut to it.
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Re: Lister UTF-8 default view

Post by *gdpr deleted 6 »

Note that this approach has unfortunately one disadvantage: Unlike the normal lister invocations, invoking the lister through execution of the TC executable does not keep the current search term active between different successive lister invocations done in this manner (and also do not carry from/to the "mother" TC instance). The search terms will become part of the list of search terms, but you can't rely on search keys/functions such as F3/F5 without the search dialog opening again in every lister instance opened in this manner. Not even adding the /O switch to the commandline will remedy this shortcoming. :(

That said, i also don't have a better suggestion to make, unfortunately. So, as of now, it's one of those cases where you take the good with the bad, i guess. But ideally, either the lister INI settings (and lister configuration dialog, too) should be enhanced to include startup options for Unicode/UTF-8 and such. Or the /O option should also be usable in conjunction with /S=, so that whatever component specified by the /S= argument is being invoked in the process context of the already running TC instance... :)
Last edited by gdpr deleted 6 on 2021-03-05, 14:21 UTC, edited 2 times in total.
User avatar
Gral
Power Member
Power Member
Posts: 1467
Joined: 2005-01-26, 15:12 UTC

Re: Lister UTF-8 default view

Post by *Gral »

Note, that my code uses main INI file, so, if you close this instance of Lister search is saved!
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Re: Lister UTF-8 default view

Post by *gdpr deleted 6 »

Gral wrote: 2021-03-05, 14:08 UTC Note, that my code uses main INI file, so, if you close this instance of Lister search is saved!
My apologies. I was sloppy in writing my previous comment, and it is a bit misleading. The search term carries over as part of the list of search terms, but it does not carry over as active search term (i.e. the search term being used when pressing F3, for example). Sorry if my sloppy expression causes some confusion. :(
I have edited and hopefully improved my previous comment...
proof
Junior Member
Junior Member
Posts: 5
Joined: 2021-03-05, 12:56 UTC

Re: Lister UTF-8 default view

Post by *proof »

Microsoft changed default encoding in Notepad from ANSI to UTF-8 in Windows 10 version 1903. Since then I always have to press 7 in Lister to see text with national characters in files with UTF-8 encoding properly. I wonder that people do not ask for this option - I guess a lot of people is using Notepad & TC with Lister to create / see notes, scripts and so on...

Anyway I changed default encoding of Notepad back to ANSI in registry, until UTF-8 default view is supported natively in TC.

Thank you both very much for help.
gdpr deleted 6
Power Member
Power Member
Posts: 872
Joined: 2013-09-04, 14:07 UTC

Re: Lister UTF-8 default view

Post by *gdpr deleted 6 »

2proof
You might try some lister plug-ins that provide an alternative to lister's built-in text modes.
CudaLister comes to mind (which can be configured to use UTF-8 as default encoding, but can also detect the presence of UTF-8 or UTF-16 BOMs): viewtopic.php?f=6&t=48685&p=396896&hilit=CudaLister#p396896

There might be other lister plug-ins that you perhaps find more suitable for your needs, but i don't know. If you like to check out available lister plug-ins, look at:
https://www.ghisler.com/plugins.htm#lister
http://totalcmd.net/directory/lister.html
User avatar
petermad
Power Member
Power Member
Posts: 14793
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Lister UTF-8 default view

Post by *petermad »

2proof
Microsoft changed default encoding in Notepad from ANSI to UTF-8 in Windows 10 version 1903. Since then I always have to press 7 in Lister to see text with national characters in files with UTF-8 encoding properly.
Hmm. out of the box TC detects UFT-8 files automatically.

If the file is saved without BOM (unfortunately default in Windows 10) then it can be a problem if there for example is only one line in the file (no line break present). I also seem to recall that it could be a problem if the first multi-byte character appears late in the file.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
proof
Junior Member
Junior Member
Posts: 5
Joined: 2021-03-05, 12:56 UTC

Re: Lister UTF-8 default view

Post by *proof »

Yes, automatic option in Lister configuration is able to detect UTF-8 and display it properly with national characters in most cases. But it also chooses e.g. binary view for some files and that is a problem for me. UTF-8 (option 7) is perfect for my needs, because it properly displays all the files that I use in expected way (-> not switching views depending on content).

I was just surprised there is such option in Lister menu and it is not possible to make it default, not even in wincmd.ini. I am grateful that you guys confirmed this, so I don't spend hours looking for that option...
User avatar
petermad
Power Member
Power Member
Posts: 14793
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Lister UTF-8 default view

Post by *petermad »

2proof
I was just surprised there is such option in Lister menu and it is not possible to make it default
You can make it default for custom defined file type(s) - for example for *.txt files Via the "Define view mode by file type" in Listers "Multimedia" configuration - see: https://madsenworld.dk/tcmd/assignuft8.png

You can define the view mode for several files types at the same time - just enter the types separated by space - like: *.txt *.ini.

You can define more than one view method for an extension (separated vith comma - like: 7,1) - then pressing '4' multiple times will change only through these methods.
Last edited by petermad on 2021-03-06, 12:01 UTC, edited 1 time in total.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
proof
Junior Member
Junior Member
Posts: 5
Joined: 2021-03-05, 12:56 UTC

Re: Lister UTF-8 default view

Post by *proof »

I used that way to make UTF-8 view default for all file types *.* and that seems to work as I need. Thanks a lot!
User avatar
petermad
Power Member
Power Member
Posts: 14793
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Lister UTF-8 default view

Post by *petermad »

2proof
I used that way to make UTF-8 view default for all file types *.*
I guess you never view images, or other media files - they don't look good in text view ;-)
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
proof
Junior Member
Junior Member
Posts: 5
Joined: 2021-03-05, 12:56 UTC

Re: Lister UTF-8 default view

Post by *proof »

No, I don't use Lister for that. When I press F3 in TC, I expect to see "the code". And I still have the possibility to switch the view manually... so I am happy now. :-)
tommy0910
Junior Member
Junior Member
Posts: 39
Joined: 2004-07-08, 09:22 UTC

Re: Lister UTF-8 default view

Post by *tommy0910 »

Is there any news on that? It's horribly annoying that I cannot get lister to start with UTF8 by default. And I don't like workarounds as with using buttons. I have exactly zero buttons in TC and do not want to have any.

And, of course I cannot speak for the original thread-starter, but for me...
petermad wrote: 2021-03-06, 11:57 UTC 2proofI guess you never view images, or other media files - they don't look good in text view ;-)
Yes, that is exactly what I want.
User avatar
petermad
Power Member
Power Member
Posts: 14793
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Lister UTF-8 default view

Post by *petermad »

2tommy0910
There is a solution without buttons - simply redefine the F3 and Shift+F3 shortcuts adding the parameter /T7

like here:
https://tcmd.madsenworld.dk/f3-utf8.png
https://tcmd.madsenworld.dk/shift-f3-utf8.png

Or put this code in the [Shortcuts] section of your wincmd.ini (and restart TC):

Code: Select all

[Shortcuts]
F3=cm_ListInternalOnly
F3_params=/T7
S+F3=cm_ListInternalMulti
S+F3_params=/T7

If you are used to having F3 showing all selected files and Shift+F3 showing only the file under cursor (Configuration -> Edit/View -> Hotkeys) then you will have to revert the remapping. so that F3 uses cm_ListInternalMulti and Shift+F3 uses cm_ListInternalOnly:

Code: Select all

[Shortcuts]
F3= cm_ListInternalMulti
F3_params=/T7
S+F3=cm_ListInternalOnly
S+F3_params=/T7
You need TC 11.00 to set parameters for redefined hotkeys.
You need TC 10.50 to use parameters with the various cm_List* commands, so for TC 10.50 and later you can also make an external command (em_command) with the cm_List* command and the parameter /T7 and then redefine the hotkeys to the em_command.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Post Reply