Why does TC create lists of files (%L %UL) always with BOM?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
PiotrMPPL
Junior Member
Junior Member
Posts: 60
Joined: 2018-10-26, 07:04 UTC

Why does TC create lists of files (%L %UL) always with BOM?

Post by *PiotrMPPL »

Hi

Why does TC create lists of files (%L %UL) always with BOM?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6973
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Why does TC create lists of files (%L %UL) always with BOM?

Post by *Horst.Epp »

The detection of character sets in different formats is easier with BOM.
I never had problems with this, in a lot of file managers, editors and other tools.
What's your specific problem with it ?
Windows 11 Home, Version 24H2 (OS Build 26100.4061)
TC 11.55 RC2 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.4 x64
User avatar
Dalai
Power Member
Power Member
Posts: 9964
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Why does TC create lists of files (%L %UL) always with BOM?

Post by *Dalai »

%L shouldn't add a BOM because it saves the list file as ANSI (without a BOM as far as I know). I suppose you mean %UL and %WL.

If a BOM exists, there is no doubt on how to interpret the following data. If there is no BOM certain characters can be ambiguous because they're valid in UTF-8 and ANSI simultaneously for example. BTW, it's documented in TC's help that %UL and %WL save the list with a BOM.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
PiotrMPPL
Junior Member
Junior Member
Posts: 60
Joined: 2018-10-26, 07:04 UTC

Re: Why does TC create lists of files (%L %UL) always with BOM?

Post by *PiotrMPPL »

How to correctly read %UL list from BOM in windows batch?

I need to read the first line from the %UL list without BOM.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50532
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Why does TC create lists of files (%L %UL) always with BOM?

Post by *ghisler(Author) »

Just cut off the first character, e.g. something like %var:~1%
Author of Total Commander
https://www.ghisler.com
User avatar
nsp
Power Member
Power Member
Posts: 1917
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Why does TC create lists of files (%L %UL) always with BOM?

Post by *nsp »

Windows batch in console do not handle Unicode correctly. You can anyhow handle some input/output in UTF-8 changing codpage to 65001.
To print, you must change console font to lucida console or one with all the char you plan to print.

UTF-16 is not supported at all even with codepage !

If you want to use utf-16, do not use batch. You can use powershell with Unicode encoding.
User avatar
milo1012
Power Member
Power Member
Posts: 1158
Joined: 2012-02-02, 19:23 UTC

Re: Why does TC create lists of files (%L %UL) always with BOM?

Post by *milo1012 »

This was actually discussed in the past several times.
I even made a suggestion to include BOM-less UTF-8 list files, years ago
viewtopic.php?t=48032
Not implemented so far, from what I can see.
nsp wrote: 2023-06-28, 14:53 UTC Windows batch in console do not handle Unicode correctly. You can anyhow handle some input/output in UTF-8 changing codpage to 65001.
To print, you must change console font to lucida console or one with all the char you plan to print.

UTF-16 is not supported at all even with codepage !

If you want to use utf-16, do not use batch. You can use powershell with Unicode encoding.
Just a small reminder :wink: :
You can type a UTF-16 list file (for loops) w/o problems in batch/cmd:
viewtopic.php?t=48032&p=335753
TC plugins: PCREsearch and RegXtract
User avatar
nsp
Power Member
Power Member
Posts: 1917
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Why does TC create lists of files (%L %UL) always with BOM?

Post by *nsp »

milo1012 wrote: 2023-06-28, 20:53 UTC Just a small reminder :wink: :
You can type a UTF-16 list file (for loops) w/o problems in batch/cmd:
viewtopic.php?t=48032&p=335753
On this thread, the only working cases are using UTF-8.

Just give a try with cmd /U with an utf-16LE file i.e test.lst
cmd /U only produce UTF-16LE output !
do a loop like

Code: Select all

for /F "usebackq tokens=* delims=" %n in ( test.lst ) do notepad "%n"
See if notepad open each unicode file name !
Post Reply