[SOLVED] Use UTF-8 with byte-order mark when creating a new .txt file

English support forum

Moderators: white, Hacker, petermad, Stefan2

browny
Senior Member
Senior Member
Posts: 288
Joined: 2007-09-10, 13:19 UTC

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *browny »

Editor should do what was required, not what someone might recommend. Be it BOM-less UTF-16LE or plain ASCII.
It was explicitly stated that CP1250 was needed, and you insist on squeezing in a BOM regardless?
Thanks, but no.
User avatar
AntonyD
Power Member
Power Member
Posts: 1249
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *AntonyD »

It looks like you really don’t fully understand what I’m writing.
An editor - any editor - of course has its own rules according to which it works with a file.
And of course - if it copes the way you need it, that’s great and you’ll be happy to use it.
BUT! There are situations/editors - when it is NECESSARY to do something preliminary so that further work is a pleasure.
So, in order to quickly solve this problem, it is proposed to introduce an option that would guarantee that when Total creates a file,
then it will be done in the encoding that I need (and in 99/100 it is UTF-8), because otherwise ALL my editors will interpret such a file as an ANSI (CP1251) encoded. And this is quite understandable in concept - because they are simply working with an empty file(0 bytes) that they did not create themselves, they were only given the path to it.
Therefore, if you simply have one pleasure and not an editor - you will not need to use this option and everything will be fine for you. But I would enable it and always get the creation of the text file I need in UTF-8 encoding.
Last edited by AntonyD on 2024-02-07, 13:36 UTC, edited 2 times in total.
#146217 personal license
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6495
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *Horst.Epp »

With my Editor (PSPad) I don't have this problem but nevertheless,
I support having an option to let TC create files with the configured requested encoding.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
TC 11.03 x64 / x86
Everything 1.5.0.1373a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
JOUBE
Power Member
Power Member
Posts: 1477
Joined: 2004-07-08, 08:58 UTC

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *JOUBE »

Horst.Epp wrote: 2024-02-07, 09:30 UTC ... an option to let TC create files with the configured requested encoding.
I don't understand that at all:
With the templates, that have just been introduced, all of this is now possible.
Or maybe not?

Joube
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6495
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *Horst.Epp »

2JOUBE
You are right, but only after assigning Shift-F4 to cm_edit with parameters :D
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
TC 11.03 x64 / x86
Everything 1.5.0.1373a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
JOUBE
Power Member
Power Member
Posts: 1477
Joined: 2004-07-08, 08:58 UTC

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *JOUBE »

Horst.Epp wrote: 2024-02-07, 11:06 UTC 2JOUBE
You are right, but only after assigning Shift-F4 to cm_edit with parameters :D
And, where is the problem to assign this?
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *tuska »

For example, how would you define the encoding: UTF-8 with byte-order mark
in a command starting with cm_Edit?

My attempt ended here:

Code: Select all

cm_Edit /CGL1N="_.txt"
I have searched the TC help for the keyword "encoding".

I know how to redefine Shift+F4 with an em_command.
browny
Senior Member
Senior Member
Posts: 288
Joined: 2007-09-10, 13:19 UTC

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *browny »

AntonyD wrote: 2024-02-07, 07:25 UTC the encoding that I need (and in 99/100 it is UTF-8)
Those who need UTF-8 less than in 1/100 cases would hardly appreciate genius idea of making it mandatory.
AntonyD wrote: 2024-02-07, 07:25 UTC otherwise ALL my editors will interpret such a file as an ANSI (CP1251) encoded.
Try AkelPad.

An alternative suggestion: Disable pre-creation of empty files for editor.
User avatar
white
Power Member
Power Member
Posts: 4623
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *white »

JOUBE wrote: 2024-02-07, 10:37 UTC I don't understand that at all:
With the templates, that have just been introduced, all of this is now possible.
tuska wrote: 2024-02-07, 13:27 UTC For example, how would you define the encoding: UTF-8 with byte-order mark
in a command starting with cm_Edit?

My attempt ended here:

Code: Select all

cm_Edit /CGL1N="_.txt"
I have searched the TC help for the keyword "encoding".
As mentioned, by using templates.
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *tuska »

white wrote: 2024-02-07, 15:01 UTC As mentioned, by using templates.
Thanks for the help to help yourself :)
Note: Without the "HISTORY.TXT" file, I probably wouldn't have been able to do this example.
  1. C:\totalcmd\Templates\UTF-8-BOM.txt -> Encoding "UTF-8 with Signature"
  2. C:\totalcmd\usercmd.ini

    Code: Select all

    [em_UTF-8-BOM_Shift-F4]
    button=
    cmd=cm_Edit
    menu=/CGL1 /T="C:\totalcmd\Templates" /N="_.txt"|https://www.ghisler.ch/board/viewtopic.php?p=449643#p449643|Sample: cm_Edit /CGL0 /T="c:\totalcmd\template" /N="<1-10>[C].xls"
    param=/CGL1 /T="C:\totalcmd\Templates" /N="_.txt"
  3. C:\totalcmd\wincmd.ini

    Code: Select all

    [Shortcuts]
    S+F4=em_UTF-8-BOM_Shift-F4
  4. Configuration > Edit/View > Editor for F4:
    C:\Users\user\AppData\Local\Programs\EmEditor\EmEditor.exe /cd "%1"
Shift+F4 immediately creates the file "_.txt" in the current directory with the encoding: "UTF-8 with Signature" in EmEditor.

If the file "UTF-16LE with Signature.txt" with this encoding is located in C:\totalcmd\Templates\ and
this is located BEFORE the file "UTF-8-BOM.txt" with this encoding, then after Shift+F4
the file "_.txt" is created (immediately! *)) with the encoding "UTF-16LE with Signature".

This means that the encoding of the first (topmost) file is used when creating a new text file with Shift+F4.
The settings in the "usercmd.ini" or "wincmd.ini" file do NOT need to be changed!
-----------------
*) Parameter /G ... --> The parameter /G ensures that the file is created IMMEDIATELY.
If this parameter is omitted, the question appears after Shift+F4: "Enter file name to edit:"
AND the name that was saved under parameter /N is suggested, e.g. /N="_.txt" --> _.txt
Only after clicking on the "OK" button is the file saved and opened in the defined editor, e.g. EmEditor.
Last edited by tuska on 2024-02-07, 19:46 UTC, edited 4 times in total.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6495
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *Horst.Epp »

JOUBE wrote: 2024-02-07, 11:39 UTC
Horst.Epp wrote: 2024-02-07, 11:06 UTC 2JOUBE
You are right, but only after assigning Shift-F4 to cm_edit with parameters :D
And, where is the problem to assign this?
There is no problem, but a new user will not know about
without intensive reading of the help.
An encoding option in the GUI config under the Editor entry would be much easier.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
TC 11.03 x64 / x86
Everything 1.5.0.1373a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6495
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *Horst.Epp »

tuska wrote: 2024-02-07, 13:27 UTC For example, how would you define the encoding: UTF-8 with byte-order mark
in a command starting with cm_Edit?
The solution is to store an empty anyname.txt file into the Template directory
which is formatted as UTF-8 with BOM.
Then redefine Shift-F4 to
cm_edit /CT
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
TC 11.03 x64 / x86
Everything 1.5.0.1373a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *tuska »

Horst.Epp wrote: 2024-02-07, 16:35 UTC
tuska wrote: 2024-02-07, 13:27 UTC For example, how would you define the encoding: UTF-8 with byte-order mark
in a command starting with cm_Edit?
The solution is to store an empty anyname.txt file into the Template directory
which is formatted as UTF-8 with BOM.
Then redefine Shift-F4 to
cm_edit /CT
Thank you, I have already solved it for me as indicated here.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6495
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *Horst.Epp »

tuska wrote: 2024-02-07, 16:40 UTC Thank you, I have already solved it for me as indicated here.
Looks rather complicated compared to my suggestion :)
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
TC 11.03 x64 / x86
Everything 1.5.0.1373a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Use UTF-8 with byte-order mark when creating a new .txt file

Post by *tuska »

Horst.Epp wrote: 2024-02-07, 18:14 UTC
tuska wrote: 2024-02-07, 16:40 UTC Thank you, I have already solved it for me as indicated here.
Looks rather complicated compared to my suggestion :)
With your suggestion:
cm_edit /CT
S+F4=em_UTF-16LE_with_Signature (only example)

I get this message:
"Enter file name to edit:"

and after entering a file name I get encoding "ANSI" in EmEditor.
This is not what I had in mind.

I would like to leave it at that and continue to use my solution above.
If anyone else is interested, perhaps you can give a detailed description.
Post Reply